Documentation
¶
Index ¶
- Constants
- type AgentEngine
- type BotEngine
- func (r *BotEngine) AfterLLMFinish(ctx context.Context, err error)
- func (r *BotEngine) BeforeLLMStart(ctx context.Context) context.Context
- func (r *BotEngine) Context() context.Context
- func (r *BotEngine) FetchHistoryMessages(ctx context.Context) []llm.Message
- func (r *BotEngine) HookOnFinish(ctx context.Context, err error)
- func (r *BotEngine) HookOnStart(ctx context.Context) context.Context
- func (r *BotEngine) RenderMessages(ctx context.Context, preset string, inputs map[string]any, query string, ...) ([]llm.Message, []string)
- func (r *BotEngine) WithContext(ctx context.Context) *BotEngine
- type ChatEngine
- type Engine
- type Event
- func EndEvent(data string) *Event
- func EndEventWithSource(data any, source, sourceID string) *Event
- func ErrorEvent(data error) *Event
- func LLMChunkEvent(data *llm.Chunk) *Event
- func LLMResultEvent(data *llm.Result) *Event
- func ToastEvent(data any) *Event
- func WorkflowEvent(evt *workflow.Event) *Event
- func WorkflowResultEvent(data *workflow.Result) *Event
- type EventName
- type EventStream
- type Extra
- type Hook
- type Input
- type Memory
- type MemoryOption
- type MemoryOptions
- type Option
- type Options
- type ProxyEngine
- type Settings
- type WorkflowEngine
Constants ¶
View Source
const ( // BotModeUnknown TODO BotModeUnknown = iota // BotModeProxy TODO BotModeProxy // BotModeChat TODO BotModeChat // BotModeWorkflow TODO BotModeWorkflow // BotModeSingleAgent TODO BotModeSingleAgent // BotModeMultiAgent TODO BotModeMultiAgent // BotModeSpeech TODO BotModeSpeech = 99 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentEngine ¶
type AgentEngine struct {
ConvID int64
MessageID int64
BotEngine
// contains filtered or unexported fields
}
AgentEngine ...
func (*AgentEngine) Execute ¶
func (engine *AgentEngine) Execute(ctx context.Context, input Input) *EventStream
Execute ... return channel ReAct mode or Function Call mode.
type BotEngine ¶
type BotEngine struct {
SessionID string
MessageID int64
HistoryMessages []llm.Message
Settings *Settings
Hooks []Hook
// contains filtered or unexported fields
}
BotEngine ...
func (*BotEngine) AfterLLMFinish ¶
AfterLLMFinish ...
func (*BotEngine) BeforeLLMStart ¶
BeforeLLMStart ...
func (*BotEngine) FetchHistoryMessages ¶
FetchHistoryMessages ...
func (*BotEngine) HookOnFinish ¶
HookOnFinish ...
func (*BotEngine) HookOnStart ¶
HookOnStart ...
type ChatEngine ¶
type ChatEngine struct {
*BotEngine
}
ChatEngine ...
func NewChatEngine ¶
func NewChatEngine(settings *Settings, opts ...Option) *ChatEngine
NewChatEngine ...
func (*ChatEngine) Execute ¶
func (r *ChatEngine) Execute(ctx context.Context, input Input) *EventStream
Execute ... return channel
type Engine ¶
type Engine interface {
Execute(ctx context.Context, input Input) *EventStream
}
Engine ...
func BuildEngine ¶
BuildEngine ...
func NewAgentEngine ¶
NewAgentEngine ...
func NewProxyEngine ¶
NewProxyEngine ...
type Event ¶
Event 消息事件接口 *llm.Chunk ThoughID string
func EndEventWithSource ¶
EndEventWithSource ...
func WorkflowResultEvent ¶
WorkflowResultEvent ...
type EventStream ¶
type EventStream struct {
// contains filtered or unexported fields
}
EventStream ...
type Hook ¶
type Hook interface {
OnStart(context.Context) context.Context
OnFinish(context.Context, error)
BeforeRetrieveStart(context.Context)
AfterRetrieveFinish(context.Context)
BeforeToolStart(context.Context, int64, map[string]any)
AfterToolFinish(context.Context, int64, map[string]any, error)
OnReasonStart(context.Context)
OnReasonFinish(context.Context)
BeforeLLMStart(context.Context) context.Context
AfterLLMFinish(context.Context, error)
}
Hook ...
type Input ¶
type Input struct {
Inputs map[string]any `json:"inputs"`
Query string `json:"query"`
TurnID string `json:"turn_id"`
SceneID string `json:"scene_id"`
Turnround int `json:"turnround"`
ChunkID string `json:"chunk_id"`
}
Input ...
type Memory ¶
type Memory interface {
FetchMemories(context.Context, int64) ([]llm.Message, error)
SaveMemory(context.Context, int64, string, *Extra) error
}
Memory ...
type MemoryOption ¶
type MemoryOption func(*MemoryOptions)
type MemoryOptions ¶
type MemoryOptions struct {
Limit int
}
type Options ¶
type Options struct {
Rag *retrival.Retrival
Memory Memory
ConversationID int64
MessageID int64
Hooks []Hook
// contains filtered or unexported fields
}
Options ...
type ProxyEngine ¶
type ProxyEngine struct {
*BotEngine
}
ProxyEngine ...
func (*ProxyEngine) Execute ¶
func (engine *ProxyEngine) Execute(ctx context.Context, input Input) *EventStream
Execute ... return channel, not support streaming
type Settings ¶
type Settings struct {
PresetPrompt string `json:"preset_prompt"`
Preamble string `json:"preamble"` // 机器人开场白
Knowledge []rag.Options `json:"knowledge"`
LLMModel struct {
Provider string `json:"provider"`
Name string `json:"name"`
} `json:"llm_model"`
Agent struct {
Mode string `json:"mode"`
MaxIteration int `json:"max_iteration"`
}
Workflow *workflow.Workflow `json:"workflow"`
Tools []string `json:"tools"`
Stream bool `json:"stream"`
}
Settings ...
type WorkflowEngine ¶
type WorkflowEngine struct {
BotEngine
}
WorkflowEngine ...
func NewWorkflowEngine ¶
func NewWorkflowEngine(settings *Settings, opts ...Option) *WorkflowEngine
NewWorkflowEngine ...
func (*WorkflowEngine) Execute ¶
func (engine *WorkflowEngine) Execute(ctx context.Context, input Input) *EventStream
Execute ... return channel, 不支持streaming
Source Files
¶
Click to show internal directories.
Click to hide internal directories.