bots

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageBotIncomingBehavior   = "message_bot_incoming"
	MessageGroupIncomingBehavior = "message_group_incoming"
)

Variables

This section is empty.

Functions

func AvailableTools

func AvailableTools() []llms.Tool

AvailableTools the tools/functions we're making available for the model.

func Behavior

func Behavior(uid types.Uid, flag string, number int)

func Bootstrap

func Bootstrap() error

func Cron

func Cron() ([]*cron.Ruleset, error)

Cron registered handlers

func FormMsg

func FormMsg(ctx types.Context, id string) types.MsgPayload

func Help

func Help(rules []interface{}) (map[string][]string, error)

func Init

func Init(jsonconf json.RawMessage) error

Init initializes registered handlers.

func InstructMsg

func InstructMsg(ctx types.Context, id string, data types.KV) types.MsgPayload

func List

func List() map[string]Handler

func PageURL

func PageURL(ctx types.Context, pageRuleId string, param types.KV, expiredDuration time.Duration) (string, error)

func Register

func Register(name string, bot Handler)

func RunCollect added in v0.18.1

func RunCollect(collectRules []collect.Rule, ctx types.Context, content types.KV) (types.MsgPayload, error)

func RunCommand

func RunCommand(commandRules []command.Rule, ctx types.Context, content interface{}) (types.MsgPayload, error)

func RunCron

func RunCron(cronRules []cron.Rule, name string) (*cron.Ruleset, error)

func RunForm

func RunForm(formRules []form.Rule, ctx types.Context, values types.KV) (types.MsgPayload, error)

func RunLangChain

func RunLangChain(langchainRules []langchain.Rule, ctx types.Context, args types.KV) (string, error)

func RunPage

func RunPage(pageRules []page.Rule, ctx types.Context, flag string) (string, error)

func RunWebhook

func RunWebhook(webhookRules []webhook.Rule, ctx types.Context, method string, data []byte) (types.MsgPayload, error)

func RunWorkflow

func RunWorkflow(workflowRules []workflow.Rule, ctx types.Context, input types.KV) (types.KV, error)

func ServiceURL

func ServiceURL(ctx types.Context, group, path string, param types.KV) string

func SettingCovertForm

func SettingCovertForm(id string, rule setting.Rule) form.Rule

func SettingGet

func SettingGet(ctx types.Context, id string, key string) (types.KV, error)

func SettingMsg

func SettingMsg(ctx types.Context, id string) types.MsgPayload

func Shortcut

func Shortcut(title, link string) (string, error)

func StoreForm

func StoreForm(ctx types.Context, payload types.MsgPayload) types.MsgPayload

func StoreInstruct

func StoreInstruct(ctx types.Context, payload types.MsgPayload) types.MsgPayload

func StorePage

func StorePage(ctx types.Context, category model.PageType, title string, payload types.MsgPayload) types.MsgPayload

func StoreParameter

func StoreParameter(params types.KV, expiredAt time.Time) (string, error)

func Webservice

func Webservice(app *fiber.App, name string, ruleset webservice.Ruleset)

Types

type Base

type Base struct{}

func (Base) Bootstrap

func (Base) Bootstrap() error

func (Base) Collect added in v0.18.1

func (Base) Collect(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Command

func (Base) Command(_ types.Context, _ interface{}) (types.MsgPayload, error)

func (Base) Cron

func (Base) Cron() (*cron.Ruleset, error)

func (Base) Form

func (Base) Form(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Help

func (b Base) Help() (map[string][]string, error)

func (Base) Input

func (Base) Input(_ types.Context, _ types.KV, _ interface{}) (types.MsgPayload, error)

func (Base) Instruct

func (Base) Instruct() (instruct.Ruleset, error)

func (Base) LangChain

func (Base) LangChain(_ types.Context, _ types.KV) (string, error)

func (Base) Page

func (Base) Page(_ types.Context, _ string) (string, error)

func (Base) Rules

func (Base) Rules() []interface{}

func (Base) WebService

func (Base) WebService() *restful.WebService

func (Base) Webhook

func (Base) Webhook(_ types.Context, _ string, _ []byte) (types.MsgPayload, error)

func (Base) Webservice

func (Base) Webservice(_ *fiber.App)

func (Base) Workflow

func (Base) Workflow(_ types.Context, _ types.KV) (types.KV, error)

type Handler

type Handler interface {
	// Init initializes the bot.
	Init(jsonconf json.RawMessage) error

	// IsReady сhecks if the bot is initialized.
	IsReady() bool

	// Bootstrap Lifecycle hook
	Bootstrap() error

	// Help return bot help
	Help() (map[string][]string, error)

	// Rules return bot ruleset
	Rules() []interface{}

	// Input return input result
	Input(ctx types.Context, head types.KV, content interface{}) (types.MsgPayload, error)

	// Command return bot result
	Command(ctx types.Context, content interface{}) (types.MsgPayload, error)

	// Form return bot form result
	Form(ctx types.Context, values types.KV) (types.MsgPayload, error)

	// Cron cron script daemon
	Cron() (*cron.Ruleset, error)

	// Collect return collect result
	Collect(ctx types.Context, content types.KV) (types.MsgPayload, error)

	// Instruct return instruct list
	Instruct() (instruct.Ruleset, error)

	// Page return page
	Page(ctx types.Context, flag string) (string, error)

	// Webservice return webservice routes
	Webservice(app *fiber.App)

	// Workflow return workflow result
	Workflow(ctx types.Context, input types.KV) (types.KV, error)

	// Webhook return webhook result
	Webhook(ctx types.Context, method string, data []byte) (types.MsgPayload, error)

	// LangChain return langchain result
	LangChain(ctx types.Context, args types.KV) (string, error)
}

Jump to

Keyboard shortcuts

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