redis

package
v0.0.0-...-8f28ad5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KeyTaskLLMStormPending is the key for LLM storm pending tasks
	KeyTaskLLMStormPending = keyPrefixTask + "llm_storm/pending"
	// KeyPrefixTaskLLMStormResult is the key prefix for LLM storm results
	//
	//  `KeyPrefixTaskLLMStormResult + <task_id>`
	KeyPrefixTaskLLMStormResult = keyPrefixTask + "llm_storm/result/"

	// KeyTaskHTMLCrawlerPending is the key for HTML crawler pending tasks
	KeyTaskHTMLCrawlerPending = keyPrefixTask + "html_crawler/pending"
	// KeyPrefixTaskHTMLCrawlerResult is the key prefix for HTML crawler results
	//
	//  `KeyPrefixTaskHTMLCrawlerResult + <task_id>`
	KeyPrefixTaskHTMLCrawlerResult = keyPrefixTask + "html_crawler/result/"
)
View Source
const (
	TaskStatusPending = "pending"
	TaskStatusRunning = "running"
	TaskStatusSuccess = "success"
	TaskStatusFailed  = "failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a wrapper for go-redis

func NewDB

func NewDB(opt *redis.Options) *DB

NewDB creates a new DB instance

func (*DB) AddHTMLCrawlerTask

func (db *DB) AddHTMLCrawlerTask(ctx context.Context, url string) (taskID string, err error)

AddHTMLCrawlerTask adds a new HTMLCrawlerTask to the queue.

func (*DB) AddLLMStormTask

func (db *DB) AddLLMStormTask(ctx context.Context,
	prompt string,
	apiKey string,
) (taskID string, err error)

AddLLMStormTask adds a new LLMStormTask to the queue.

func (*DB) GetDB

func (db *DB) GetDB() *gredis.Utils

GetDB returns the underlying go-redis client

func (*DB) GetHTMLCrawlerTask

func (db *DB) GetHTMLCrawlerTask(ctx context.Context) (task *HTMLCrawlerTask, err error)

GetHTMLCrawlerTask is to get a HTMLCrawlerTask from the queue.

func (*DB) GetHTMLCrawlerTaskResult

func (db *DB) GetHTMLCrawlerTaskResult(ctx context.Context, taskID string) (task *HTMLCrawlerTask, err error)

GetHTMLCrawlerTaskResult gets the result of a HTMLCrawlerTask by taskID.

func (*DB) GetLLMStormTaskResult

func (db *DB) GetLLMStormTaskResult(ctx context.Context, taskID string) (task *LLMStormTask, err error)

GetLLMStormTaskResult gets the result of a LLMStormTask by taskID.

type HTMLCrawlerTask

type HTMLCrawlerTask struct {
	Url        string `json:"url"`
	ResultHTML []byte `json:"result_html,omitempty"`
	// contains filtered or unexported fields
}

HTMLCrawlerTask is a task for crawling HTML pages.

func NewHTMLCrawlerTask

func NewHTMLCrawlerTask(url string) *HTMLCrawlerTask

NewHTMLCrawlerTask creates a new HTMLCrawlerTask instance.

func NewHTMLCrawlerTaskFromString

func NewHTMLCrawlerTaskFromString(taskStr string) (*HTMLCrawlerTask, error)

NewHTMLCrawlerTaskFromString creates a HTMLCrawlerTask instance from its JSON string representation.

func (*HTMLCrawlerTask) ToString

func (s *HTMLCrawlerTask) ToString() (string, error)

ToString returns the JSON representation of a HTMLCrawlerTask.

type LLMStormTask

type LLMStormTask struct {
	Prompt           string           `json:"prompt"`
	APIKey           string           `json:"api_key"`
	ResultArticle    *string          `json:"result_article,omitempty"`
	ResultReferences *stormReferences `json:"result_references,omitempty"`
	// Runner is the name of the runner that processed the task
	Runner string `json:"runner"`
	// contains filtered or unexported fields
}

func NewLLMStormTask

func NewLLMStormTask(prompt, apikey string) *LLMStormTask

NewLLMStormTask creates a new StormTask instance.

func NewLLMStormTaskFromString

func NewLLMStormTaskFromString(taskStr string) (*LLMStormTask, error)

NewLLMStormTaskFromString creates a StormTask instance from its JSON string representation.

func (*LLMStormTask) ToString

func (s *LLMStormTask) ToString() (string, error)

ToString returns the JSON representation of a StormTask.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL