Documentation
¶
Index ¶
- Constants
- type DB
- func (db *DB) AddHTMLCrawlerTask(ctx context.Context, url string) (taskID string, err error)
- func (db *DB) AddLLMStormTask(ctx context.Context, prompt string, apiKey string) (taskID string, err error)
- func (db *DB) GetDB() *gredis.Utils
- func (db *DB) GetHTMLCrawlerTask(ctx context.Context) (task *HTMLCrawlerTask, err error)
- func (db *DB) GetHTMLCrawlerTaskResult(ctx context.Context, taskID string) (task *HTMLCrawlerTask, err error)
- func (db *DB) GetLLMStormTaskResult(ctx context.Context, taskID string) (task *LLMStormTask, err error)
- type HTMLCrawlerTask
- type LLMStormTask
Constants ¶
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/" )
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 (*DB) AddHTMLCrawlerTask ¶
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) 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.