Documentation
¶
Index ¶
- Variables
- func InvokeReAct(input string, options ...AIEngineConfigOption) error
- type AIEngine
- func (e *AIEngine) Close()
- func (e *AIEngine) GetActiveTaskCount() int
- func (e *AIEngine) GetReAct() *aireact.ReAct
- func (e *AIEngine) IsFinished() bool
- func (e *AIEngine) SendInteractiveResponse(response string) error
- func (e *AIEngine) SendMsg(input string) error
- func (e *AIEngine) SendMsgAsync(input string) error
- func (e *AIEngine) Wait()
- func (e *AIEngine) WaitTaskFinish() error
- func (e *AIEngine) WaitTaskFinishByTaskName(taskID string) error
- type AIEngineConfig
- type AIEngineConfigOption
- func WithAICallback(callback aicommon.AICallbackType) AIEngineConfigOption
- func WithAIConfig(typeName string, opts ...aispec.AIConfigOption) AIEngineConfigOption
- func WithAIReviewMode() AIEngineConfigOption
- func WithAIService(service string) AIEngineConfigOption
- func WithAllowUserInteract(allow bool) AIEngineConfigOption
- func WithContext(ctx context.Context) AIEngineConfigOption
- func WithDebugMode(debug bool) AIEngineConfigOption
- func WithDisableAIForge(disable bool) AIEngineConfigOption
- func WithDisableMCPServers(disable bool) AIEngineConfigOption
- func WithDisableToolUse(disable bool) AIEngineConfigOption
- func WithEnableAISearchTool(enable bool) AIEngineConfigOption
- func WithEnableForgeSearchTool(enable bool) AIEngineConfigOption
- func WithExcludeToolNames(names ...string) AIEngineConfigOption
- func WithExtOptions(opts ...aicommon.ConfigOption) AIEngineConfigOption
- func WithFocus(focus string) AIEngineConfigOption
- func WithIncludeToolNames(names ...string) AIEngineConfigOption
- func WithKeywords(keywords ...string) AIEngineConfigOption
- func WithLanguage(lang string) AIEngineConfigOption
- func WithManualMode() AIEngineConfigOption
- func WithMaxIteration(max int) AIEngineConfigOption
- func WithOnData(...) AIEngineConfigOption
- func WithOnEvent(callback func(*aireact.ReAct, *schema.AiOutputEvent)) AIEngineConfigOption
- func WithOnFinished(callback func(react *aireact.ReAct)) AIEngineConfigOption
- func WithOnInputRequired(callback func(react *aireact.ReAct, question string) string) AIEngineConfigOption
- func WithOnInputRequiredRaw(...) AIEngineConfigOption
- func WithOnStream(...) AIEngineConfigOption
- func WithOnStreamEnd(...) AIEngineConfigOption
- func WithReviewPolicy(policy string) AIEngineConfigOption
- func WithSessionID(sessionID string) AIEngineConfigOption
- func WithTimelineContentLimit(limit int) AIEngineConfigOption
- func WithTimeout(timeout float64) AIEngineConfigOption
- func WithUserInteractLimit(limit int64) AIEngineConfigOption
- func WithWorkdir(workdir string) AIEngineConfigOption
- func WithYOLOMode() AIEngineConfigOption
Constants ¶
This section is empty.
Variables ¶
var Exports = map[string]interface{}{ "InvokeReAct": InvokeReAct, "InvokeReActAsync": InvokeReActAsync, "NewAIEngine": NewAIEngine, "focus": WithFocus, "timeout": WithTimeout, "context": WithContext, "aiService": WithAIService, "maxIteration": WithMaxIteration, "sessionID": WithSessionID, "workdir": WithWorkdir, "language": WithLanguage, "disableToolUse": WithDisableToolUse, "disableAIForge": WithDisableAIForge, "disableMCPServers": WithDisableMCPServers, "enableAISearchTool": WithEnableAISearchTool, "enableForgeSearchTool": WithEnableForgeSearchTool, "includeToolNames": WithIncludeToolNames, "excludeToolNames": WithExcludeToolNames, "keywords": WithKeywords, "allowUserInteract": WithAllowUserInteract, "reviewPolicy": WithReviewPolicy, "userInteractLimit": WithUserInteractLimit, "timelineContentLimit": WithTimelineContentLimit, "debugMode": WithDebugMode, "onEvent": WithOnEvent, "onStream": WithOnStream, "onStreamEnd": WithOnStreamEnd, "onData": WithOnData, "onFinished": WithOnFinished, "onInputRequiredRaw": WithOnInputRequiredRaw, "onInputRequired": WithOnInputRequired, "yoloMode": WithYOLOMode, "manualMode": WithManualMode, "aiReviewMode": WithAIReviewMode, "aiCallback": WithAICallback, "aiConfig": WithAIConfig, }
Functions ¶
func InvokeReAct ¶
func InvokeReAct(input string, options ...AIEngineConfigOption) error
Types ¶
type AIEngine ¶
type AIEngine struct {
// contains filtered or unexported fields
}
AIEngine AI 引擎封装 提供简化的 API 来使用 ReAct 和其他 AI 功能
func InvokeReActAsync ¶
func InvokeReActAsync(input string, options ...AIEngineConfigOption) (*AIEngine, error)
InvokeReActAsync 异步执行 ReAct 任务,并返回引擎实例
func NewAIEngine ¶
func NewAIEngine(options ...AIEngineConfigOption) (*AIEngine, error)
NewAIEngine 创建新的 AI 引擎实例
func (*AIEngine) GetActiveTaskCount ¶
GetActiveTaskCount 获取当前活跃任务数量
func (*AIEngine) SendInteractiveResponse ¶
SendInteractiveResponse 发送交互式响应 用于回复 AI 提出的问题或需要用户确认的操作
func (*AIEngine) SendMsgAsync ¶
SendMsgAsync 异步执行 AI 任务(立即返回)
func (*AIEngine) WaitTaskFinish ¶
WaitTaskFinish 等待所有任务完成 通过监听任务状态变化来判断所有任务是否完成
func (*AIEngine) WaitTaskFinishByTaskName ¶
WaitTaskFinishByTaskName 等待指定任务完成 传入任务ID,等待该任务状态变为 Completed 或 Aborted
type AIEngineConfig ¶
type AIEngineConfig struct {
// 基础配置
Context context.Context
Timeout float64
// AI 服务配置
AIService string // AI 服务名称,如 "openai", "deepseek" 等
AICallback aicommon.AICallbackType
// 执行配置
MaxIteration int // 最大迭代次数,默认 10
SessionID string // 会话 ID,用于持久化
// 工具配置
DisableToolUse bool // 禁用工具调用
DisableAIForge bool // 禁用 Forge 调用
DisableMCPServers bool // 禁用 MCPServers
EnableAISearchTool bool // 启用 AI 搜索工具
EnableForgeSearchTool bool // 启用 Forge 搜索工具,默认启用
IncludeToolNames []string // 包含的工具名称
ExcludeToolNames []string // 排除的工具名称
Keywords []string // 关键词,用于工具搜索
// 交互配置
AllowUserInteract bool // 允许用户交互
ReviewPolicy string // 审批策略: "yolo", "ai", "manual"
UserInteractLimit int64 // 用户交互次数限制
// 内容限制
TimelineContentLimit int // Timeline 内容大小限制
// 调试配置
DebugMode bool // 调试模式
// 事件处理回调
OnEvent func(react *aireact.ReAct, event *schema.AiOutputEvent) // 事件回调
OnStream func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string, data []byte) // 流式输出回调
OnStreamEnd func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string) // 流式输出结束
OnData func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string, data []byte) // 数据回调
OnFinished func(react *aireact.ReAct) // 完成回调, 不返回结果
OnInputRequiredRaw func(react *aireact.ReAct, event *schema.AiOutputEvent, question string) string // 需要用户输入回调
OnInputRequired func(react *aireact.ReAct, question string) string // 需要用户输入回调
// 高级配置
Focus string // 焦点,用于聚焦某个任务,如 yaklang_code
Workdir string // 工作目录
Language string // 响应语言偏好
ExtOptions []aicommon.ConfigOption
}
AIEngineConfig 简化的 AI 引擎配置 提供更友好的 API 来配置 ReAct 实例
func NewAIEngineConfig ¶
func NewAIEngineConfig(options ...AIEngineConfigOption) *AIEngineConfig
NewAIEngineConfig 创建默认配置
func (*AIEngineConfig) ConvertToYPBAIStartParams ¶
func (c *AIEngineConfig) ConvertToYPBAIStartParams() *ypb.AIStartParams
ConvertToYPBAIStartParams 将 AIEngineConfig 转换为 YPB 的 AIStartParams 用于与现有的 gRPC 接口兼容
type AIEngineConfigOption ¶
type AIEngineConfigOption func(*AIEngineConfig)
AIEngineConfigOption 配置选项函数
func WithAICallback ¶
func WithAICallback(callback aicommon.AICallbackType) AIEngineConfigOption
WithAICallback 设置 AI 回调
func WithAIConfig ¶
func WithAIConfig(typeName string, opts ...aispec.AIConfigOption) AIEngineConfigOption
func WithAIReviewMode ¶
func WithAIReviewMode() AIEngineConfigOption
WithAIReviewMode AI 审批模式:由 AI 决定是否需要用户确认
func WithAllowUserInteract ¶
func WithAllowUserInteract(allow bool) AIEngineConfigOption
WithAllowUserInteract 设置是否允许用户交互
func WithDisableAIForge ¶
func WithDisableAIForge(disable bool) AIEngineConfigOption
func WithDisableMCPServers ¶
func WithDisableMCPServers(disable bool) AIEngineConfigOption
func WithDisableToolUse ¶
func WithDisableToolUse(disable bool) AIEngineConfigOption
WithDisableToolUse 禁用工具调用
func WithEnableAISearchTool ¶
func WithEnableAISearchTool(enable bool) AIEngineConfigOption
WithEnableAISearchTool 启用 AI 搜索工具
func WithEnableForgeSearchTool ¶
func WithEnableForgeSearchTool(enable bool) AIEngineConfigOption
WithEnableForgeSearchTool 启用 Forge 搜索工具
func WithExcludeToolNames ¶
func WithExcludeToolNames(names ...string) AIEngineConfigOption
WithExcludeToolNames 设置排除的工具名称
func WithExtOptions ¶
func WithExtOptions(opts ...aicommon.ConfigOption) AIEngineConfigOption
func WithIncludeToolNames ¶
func WithIncludeToolNames(names ...string) AIEngineConfigOption
WithIncludeToolNames 设置包含的工具名称
func WithMaxIteration ¶
func WithMaxIteration(max int) AIEngineConfigOption
WithMaxIteration 设置最大迭代次数
func WithOnData ¶
func WithOnData(callback func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string, data []byte)) AIEngineConfigOption
WithOnData 设置数据回调
func WithOnEvent ¶
func WithOnEvent(callback func(*aireact.ReAct, *schema.AiOutputEvent)) AIEngineConfigOption
WithOnEvent 设置事件回调
func WithOnFinished ¶
func WithOnFinished(callback func(react *aireact.ReAct)) AIEngineConfigOption
WithOnFinished 设置完成回调
func WithOnInputRequired ¶
func WithOnInputRequired(callback func(react *aireact.ReAct, question string) string) AIEngineConfigOption
WithOnInputRequired 设置需要用户输入回调
func WithOnInputRequiredRaw ¶
func WithOnInputRequiredRaw(callback func(react *aireact.ReAct, event *schema.AiOutputEvent, question string) string) AIEngineConfigOption
WithOnInputRequiredRaw 设置需要用户输入回调
func WithOnStream ¶
func WithOnStream(callback func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string, data []byte)) AIEngineConfigOption
WithOnStream 设置流式输出回调
func WithOnStreamEnd ¶
func WithOnStreamEnd(callback func(react *aireact.ReAct, event *schema.AiOutputEvent, NodeId string)) AIEngineConfigOption
WithOnStreamEnd 设置流式输出结束回调
func WithReviewPolicy ¶
func WithReviewPolicy(policy string) AIEngineConfigOption
WithReviewPolicy 设置审批策略 policy: "yolo" (自动通过), "ai" (AI 审批), "manual" (手动审批)
func WithSessionID ¶
func WithSessionID(sessionID string) AIEngineConfigOption
WithSessionID 设置会话 ID
func WithTimelineContentLimit ¶
func WithTimelineContentLimit(limit int) AIEngineConfigOption
WithTimelineContentLimit 设置 Timeline 内容大小限制
func WithTimeout ¶
func WithTimeout(timeout float64) AIEngineConfigOption
func WithUserInteractLimit ¶
func WithUserInteractLimit(limit int64) AIEngineConfigOption
WithUserInteractLimit 设置用户交互次数限制