executor

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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

Execute 执行 Agent 输入

func (*AgentExecutor) ExecuteWithCallbacks

func (e *AgentExecutor) ExecuteWithCallbacks(
	ctx context.Context,
	input *agentcore.AgentInput,
	callbacks ...agentcore.Callback,
) (*agentcore.AgentOutput, error)

ExecuteWithCallbacks 使用回调执行

func (*AgentExecutor) GetMemory

func (e *AgentExecutor) GetMemory() Memory

GetMemory 获取记忆系统

func (*AgentExecutor) GetTools

func (e *AgentExecutor) GetTools() []interfaces.Tool

GetTools 获取可用工具

func (*AgentExecutor) Run

func (e *AgentExecutor) Run(ctx context.Context, input string) (string, error)

Run 执行 Agent

func (*AgentExecutor) SetMemory

func (e *AgentExecutor) SetMemory(mem Memory)

SetMemory 设置记忆系统

func (*AgentExecutor) SetVerbose

func (e *AgentExecutor) SetVerbose(verbose bool)

SetVerbose 设置详细输出

func (*AgentExecutor) Stream

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)

Jump to

Keyboard shortcuts

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