Documentation
¶
Index ¶
- type AgentExecutor
- func (e *AgentExecutor) Batch(ctx context.Context, inputs []*agentcore.AgentInput) ([]*agentcore.AgentOutput, error)
- func (e *AgentExecutor) Execute(ctx context.Context, input *agentcore.AgentInput) (*agentcore.AgentOutput, error)
- func (e *AgentExecutor) ExecuteWithCallbacks(ctx context.Context, input *agentcore.AgentInput, ...) (*agentcore.AgentOutput, error)
- func (e *AgentExecutor) GetMemory() Memory
- func (e *AgentExecutor) GetTools() []interfaces.Tool
- func (e *AgentExecutor) Run(ctx context.Context, input string) (string, error)
- func (e *AgentExecutor) SetMemory(mem Memory)
- func (e *AgentExecutor) SetVerbose(verbose bool)
- func (e *AgentExecutor) Stream(ctx context.Context, input *agentcore.AgentInput) (<-chan agentcore.StreamChunk[*agentcore.AgentOutput], error)
- type ConversationChain
- func (c *ConversationChain) Chat(ctx context.Context, message string, sessionID string) (string, error)
- func (c *ConversationChain) ClearMemory(ctx context.Context, sessionID string) error
- func (c *ConversationChain) GetHistory(ctx context.Context, sessionID string) ([]map[string]interface{}, error)
- type ExecutorConfig
- type Memory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentExecutor ¶
type AgentExecutor struct {
// contains filtered or unexported fields
}
AgentExecutor Agent 执行器
提供高级的执行逻辑,包括: - 记忆管理 - 对话历史 - 工具管理 - 错误处理和重试 - 早停机制
func NewAgentExecutor ¶
func NewAgentExecutor(config ExecutorConfig) *AgentExecutor
NewAgentExecutor 创建 Agent 执行器
func (*AgentExecutor) Batch ¶
func (e *AgentExecutor) Batch( ctx context.Context, inputs []*agentcore.AgentInput, ) ([]*agentcore.AgentOutput, error)
Batch 批量执行
func (*AgentExecutor) Execute ¶
func (e *AgentExecutor) Execute(ctx context.Context, input *agentcore.AgentInput) (*agentcore.AgentOutput, error)
Execute 执行 Agent 输入
func (*AgentExecutor) ExecuteWithCallbacks ¶
func (e *AgentExecutor) ExecuteWithCallbacks( ctx context.Context, input *agentcore.AgentInput, callbacks ...agentcore.Callback, ) (*agentcore.AgentOutput, error)
ExecuteWithCallbacks 使用回调执行
func (*AgentExecutor) GetTools ¶
func (e *AgentExecutor) GetTools() []interfaces.Tool
GetTools 获取可用工具
func (*AgentExecutor) SetVerbose ¶
func (e *AgentExecutor) SetVerbose(verbose bool)
SetVerbose 设置详细输出
func (*AgentExecutor) Stream ¶
func (e *AgentExecutor) Stream( ctx context.Context, input *agentcore.AgentInput, ) (<-chan agentcore.StreamChunk[*agentcore.AgentOutput], error)
Stream 流式执行
type ConversationChain ¶
type ConversationChain struct {
*AgentExecutor
// contains filtered or unexported fields
}
ConversationChain 对话链
专门用于对话场景的执行器
func NewConversationChain ¶
func NewConversationChain(agent agentcore.Agent, mem Memory) *ConversationChain
NewConversationChain 创建对话链
func (*ConversationChain) Chat ¶
func (c *ConversationChain) Chat(ctx context.Context, message string, sessionID string) (string, error)
Chat 进行对话
func (*ConversationChain) ClearMemory ¶
func (c *ConversationChain) ClearMemory(ctx context.Context, sessionID string) error
ClearMemory 清除对话记忆
func (*ConversationChain) GetHistory ¶
func (c *ConversationChain) GetHistory(ctx context.Context, sessionID string) ([]map[string]interface{}, error)
GetHistory 获取对话历史
type ExecutorConfig ¶
type ExecutorConfig struct {
Agent agentcore.Agent // Agent 实例
Tools []interfaces.Tool // 可用工具
Memory Memory // 记忆系统
MaxIterations int // 最大迭代次数
MaxExecutionTime time.Duration // 最大执行时间
EarlyStoppingMethod string // 早停方法: "force", "generate"
HandleParsingErrors bool // 是否处理解析错误
ReturnIntermSteps bool // 是否返回中间步骤
Verbose bool // 是否详细输出
}
ExecutorConfig 执行器配置
type Memory ¶
type Memory interface {
// SaveContext 保存上下文
SaveContext(ctx context.Context, sessionID string, input, output map[string]interface{}) error
// LoadHistory 加载历史
LoadHistory(ctx context.Context, sessionID string) ([]map[string]interface{}, error)
// Clear 清除记忆
Clear(ctx context.Context, sessionID string) error
}
Memory 定义记忆系统接口(简化版,适配 memory.Manager)
Click to show internal directories.
Click to hide internal directories.