Documentation
¶
Index ¶
- func ConvertReActLoopFactoryToActionFactory(name string, factory LoopFactory) func(r aicommon.AIInvokeRuntime) (*LoopAction, error)
- func RegisterAction(action *LoopAction)
- func RegisterLoopFactory(name string, creator LoopFactory) error
- type ContextProviderFunc
- type FeedbackProviderFunc
- type LoopAITagField
- type LoopAction
- type LoopActionFactory
- type LoopActionHandlerFunc
- type LoopActionHandlerOperator
- func (l *LoopActionHandlerOperator) Continue()
- func (l *LoopActionHandlerOperator) DisallowNextLoopExit()
- func (l *LoopActionHandlerOperator) Exit()
- func (l *LoopActionHandlerOperator) Fail(i any)
- func (l *LoopActionHandlerOperator) Feedback(i any)
- func (r *LoopActionHandlerOperator) GetContext() context.Context
- func (l *LoopActionHandlerOperator) GetDisallowLoopExit() bool
- func (l *LoopActionHandlerOperator) GetFeedback() *bytes.Buffer
- func (l *LoopActionHandlerOperator) GetTask() aicommon.AIStatefulTask
- func (l *LoopActionHandlerOperator) IsContinued() bool
- func (l *LoopActionHandlerOperator) IsTerminated() (bool, error)
- func (l *LoopActionHandlerOperator) MarkSilence(i ...bool)
- type LoopActionVerifierFunc
- type LoopFactory
- type LoopStreamField
- type ReActLoop
- func (r *ReActLoop) DisallowAskForClarification()
- func (r *ReActLoop) Execute(taskId string, ctx context.Context, userInput string) error
- func (r *ReActLoop) ExecuteWithExistedTask(task aicommon.AIStatefulTask) error
- func (r *ReActLoop) FinishAsyncTask(t aicommon.AIStatefulTask, err error)
- func (r *ReActLoop) Get(i string) string
- func (r *ReActLoop) GetActionHandler(actionName string) (*LoopAction, error)
- func (r *ReActLoop) GetAllActionNames() []string
- func (r *ReActLoop) GetAllActions() []*LoopAction
- func (r *ReActLoop) GetConfig() aicommon.AICallerConfigIf
- func (r *ReActLoop) GetCurrentMemoriesContent() string
- func (r *ReActLoop) GetCurrentTask() aicommon.AIStatefulTask
- func (r *ReActLoop) GetEmitter() *aicommon.Emitter
- func (r *ReActLoop) GetInt(k string) int
- func (r *ReActLoop) GetInvoker() aicommon.AIInvokeRuntime
- func (r *ReActLoop) GetMemoryTriage() aimem.MemoryTriage
- func (r *ReActLoop) GetStringSlice(i string) []string
- func (r *ReActLoop) GetVariable(i string) any
- func (r *ReActLoop) NoActions() bool
- func (r *ReActLoop) OnAsyncTaskFinished(f func(task aicommon.AIStatefulTask))
- func (r *ReActLoop) OnAsyncTaskTrigger(f func(ins *LoopAction, task aicommon.AIStatefulTask))
- func (r *ReActLoop) OnTaskCreated(f func(task aicommon.AIStatefulTask))
- func (r *ReActLoop) PushMemory(result *aimem.SearchMemoryResult)
- func (r *ReActLoop) RemoveAction(actionType string)
- func (r *ReActLoop) Set(i string, result any)
- func (r *ReActLoop) SetCurrentTask(t aicommon.AIStatefulTask)
- type ReActLoopCoreGenerateCode
- type ReActLoopOption
- func WithAITagField(tagName, variableName string) ReActLoopOption
- func WithAITagFieldWithAINodeId(tagName, variableName, nodeId string) ReActLoopOption
- func WithActionFactoryFromLoop(name string) ReActLoopOption
- func WithAllowAIForge(b ...bool) ReActLoopOption
- func WithAllowAIForgeGetter(allowAIForge func() bool) ReActLoopOption
- func WithAllowPlanAndExec(b ...bool) ReActLoopOption
- func WithAllowPlanAndExecGetter(allowPlanAndExec func() bool) ReActLoopOption
- func WithAllowRAG(b ...bool) ReActLoopOption
- func WithAllowRAGGetter(allowRAG func() bool) ReActLoopOption
- func WithAllowToolCall(b ...bool) ReActLoopOption
- func WithAllowToolCallGetter(allowToolCall func() bool) ReActLoopOption
- func WithAllowUserInteract(b ...bool) ReActLoopOption
- func WithInitTask(initHandler func(loop *ReActLoop, task aicommon.AIStatefulTask) error) ReActLoopOption
- func WithLoopPromptGenerator(generator ReActLoopCoreGenerateCode) ReActLoopOption
- func WithMaxIterations(maxIterations int) ReActLoopOption
- func WithMemoryPool(pool *omap.OrderedMap[string, *aimem.MemoryEntity]) ReActLoopOption
- func WithMemorySizeLimit(sizeLimit int) ReActLoopOption
- func WithMemoryTriage(triage aimem.MemoryTriage) ReActLoopOption
- func WithOnAsyncTaskFinished(fn func(task aicommon.AIStatefulTask)) ReActLoopOption
- func WithOnAsyncTaskTrigger(fn func(i *LoopAction, task aicommon.AIStatefulTask)) ReActLoopOption
- func WithOnPostIteraction(...) ReActLoopOption
- func WithOnTaskCreated(fn func(task aicommon.AIStatefulTask)) ReActLoopOption
- func WithPersistentContextProvider(provider ContextProviderFunc) ReActLoopOption
- func WithPersistentInstruction(instruction string) ReActLoopOption
- func WithReactiveDataBuilder(provider FeedbackProviderFunc) ReActLoopOption
- func WithReflectionOutputExample(example string) ReActLoopOption
- func WithReflectionOutputExampleContextProvider(provider ContextProviderFunc) ReActLoopOption
- func WithRegisterLoopAction(actionName string, desc string, opts []aitool.ToolOption, ...) ReActLoopOption
- func WithRegisterLoopActionWithStreamField(actionName string, desc string, opts []aitool.ToolOption, ...) ReActLoopOption
- func WithToolsGetter(getter func() []*aitool.Tool) ReActLoopOption
- func WithUserInteractGetter(allowUserInteract func() bool) ReActLoopOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertReActLoopFactoryToActionFactory ¶
func ConvertReActLoopFactoryToActionFactory( name string, factory LoopFactory, ) func(r aicommon.AIInvokeRuntime) (*LoopAction, error)
func RegisterAction ¶
func RegisterAction(action *LoopAction)
func RegisterLoopFactory ¶
func RegisterLoopFactory( name string, creator LoopFactory, ) error
Types ¶
type ContextProviderFunc ¶
type FeedbackProviderFunc ¶
type LoopAITagField ¶
type LoopAction ¶
type LoopAction struct {
// plan 与 forge executor 会允许支持异步执行,异步情况下仍然允许对话和其他功能
AsyncMode bool
ActionType string `json:"type"`
Description string `json:"description"`
Options []aitool.ToolOption
ActionVerifier LoopActionVerifierFunc
ActionHandler LoopActionHandlerFunc
StreamFields []*LoopStreamField
AITagStreamFields []*LoopAITagField
}
func GetLoopAction ¶
func GetLoopAction(name string) (*LoopAction, bool)
type LoopActionFactory ¶
type LoopActionFactory func(r aicommon.AIInvokeRuntime) (*LoopAction, error)
type LoopActionHandlerFunc ¶
type LoopActionHandlerFunc func(loop *ReActLoop, action *aicommon.Action, operator *LoopActionHandlerOperator)
type LoopActionHandlerOperator ¶
type LoopActionHandlerOperator struct {
// contains filtered or unexported fields
}
func (*LoopActionHandlerOperator) Continue ¶
func (l *LoopActionHandlerOperator) Continue()
func (*LoopActionHandlerOperator) DisallowNextLoopExit ¶
func (l *LoopActionHandlerOperator) DisallowNextLoopExit()
func (*LoopActionHandlerOperator) Exit ¶
func (l *LoopActionHandlerOperator) Exit()
func (*LoopActionHandlerOperator) Fail ¶
func (l *LoopActionHandlerOperator) Fail(i any)
func (*LoopActionHandlerOperator) Feedback ¶
func (l *LoopActionHandlerOperator) Feedback(i any)
func (*LoopActionHandlerOperator) GetContext ¶
func (r *LoopActionHandlerOperator) GetContext() context.Context
func (*LoopActionHandlerOperator) GetDisallowLoopExit ¶
func (l *LoopActionHandlerOperator) GetDisallowLoopExit() bool
func (*LoopActionHandlerOperator) GetFeedback ¶
func (l *LoopActionHandlerOperator) GetFeedback() *bytes.Buffer
func (*LoopActionHandlerOperator) GetTask ¶
func (l *LoopActionHandlerOperator) GetTask() aicommon.AIStatefulTask
func (*LoopActionHandlerOperator) IsContinued ¶
func (l *LoopActionHandlerOperator) IsContinued() bool
func (*LoopActionHandlerOperator) IsTerminated ¶
func (l *LoopActionHandlerOperator) IsTerminated() (bool, error)
func (*LoopActionHandlerOperator) MarkSilence ¶
func (l *LoopActionHandlerOperator) MarkSilence(i ...bool)
type LoopActionVerifierFunc ¶
type LoopFactory ¶
type LoopFactory func(r aicommon.AIInvokeRuntime, opts ...ReActLoopOption) (*ReActLoop, error)
func GetLoopFactory ¶
func GetLoopFactory(name string) (LoopFactory, bool)
type LoopStreamField ¶
type ReActLoop ¶
type ReActLoop struct {
// contains filtered or unexported fields
}
func CreateLoopByName ¶
func CreateLoopByName(name string, invoker aicommon.AIInvokeRuntime, opts ...ReActLoopOption) (*ReActLoop, error)
func NewReActLoop ¶
func NewReActLoop(name string, invoker aicommon.AIInvokeRuntime, options ...ReActLoopOption) (*ReActLoop, error)
func (*ReActLoop) DisallowAskForClarification ¶
func (r *ReActLoop) DisallowAskForClarification()
func (*ReActLoop) ExecuteWithExistedTask ¶
func (r *ReActLoop) ExecuteWithExistedTask(task aicommon.AIStatefulTask) error
func (*ReActLoop) FinishAsyncTask ¶
func (r *ReActLoop) FinishAsyncTask(t aicommon.AIStatefulTask, err error)
func (*ReActLoop) GetActionHandler ¶
func (r *ReActLoop) GetActionHandler(actionName string) (*LoopAction, error)
func (*ReActLoop) GetAllActionNames ¶
func (*ReActLoop) GetAllActions ¶
func (r *ReActLoop) GetAllActions() []*LoopAction
func (*ReActLoop) GetConfig ¶
func (r *ReActLoop) GetConfig() aicommon.AICallerConfigIf
func (*ReActLoop) GetCurrentMemoriesContent ¶
func (*ReActLoop) GetCurrentTask ¶
func (r *ReActLoop) GetCurrentTask() aicommon.AIStatefulTask
func (*ReActLoop) GetEmitter ¶
func (*ReActLoop) GetInvoker ¶
func (r *ReActLoop) GetInvoker() aicommon.AIInvokeRuntime
func (*ReActLoop) GetMemoryTriage ¶
func (r *ReActLoop) GetMemoryTriage() aimem.MemoryTriage
func (*ReActLoop) GetStringSlice ¶
func (*ReActLoop) GetVariable ¶
func (*ReActLoop) OnAsyncTaskFinished ¶
func (r *ReActLoop) OnAsyncTaskFinished(f func(task aicommon.AIStatefulTask))
func (*ReActLoop) OnAsyncTaskTrigger ¶
func (r *ReActLoop) OnAsyncTaskTrigger(f func(ins *LoopAction, task aicommon.AIStatefulTask))
func (*ReActLoop) OnTaskCreated ¶
func (r *ReActLoop) OnTaskCreated(f func(task aicommon.AIStatefulTask))
func (*ReActLoop) PushMemory ¶
func (r *ReActLoop) PushMemory(result *aimem.SearchMemoryResult)
func (*ReActLoop) RemoveAction ¶
func (*ReActLoop) SetCurrentTask ¶
func (r *ReActLoop) SetCurrentTask(t aicommon.AIStatefulTask)
type ReActLoopOption ¶
type ReActLoopOption func(r *ReActLoop)
func WithAITagField ¶
func WithAITagField(tagName, variableName string) ReActLoopOption
WithAITagField 行为变化!!!:现在VariableName 不仅仅是在loop中get数据的key,也是tag set到action的field的key
func WithAITagFieldWithAINodeId ¶
func WithAITagFieldWithAINodeId(tagName, variableName, nodeId string) ReActLoopOption
func WithActionFactoryFromLoop ¶
func WithActionFactoryFromLoop(name string) ReActLoopOption
func WithAllowAIForge ¶
func WithAllowAIForge(b ...bool) ReActLoopOption
func WithAllowAIForgeGetter ¶
func WithAllowAIForgeGetter(allowAIForge func() bool) ReActLoopOption
func WithAllowPlanAndExec ¶
func WithAllowPlanAndExec(b ...bool) ReActLoopOption
func WithAllowPlanAndExecGetter ¶
func WithAllowPlanAndExecGetter(allowPlanAndExec func() bool) ReActLoopOption
func WithAllowRAG ¶
func WithAllowRAG(b ...bool) ReActLoopOption
func WithAllowRAGGetter ¶
func WithAllowRAGGetter(allowRAG func() bool) ReActLoopOption
func WithAllowToolCall ¶
func WithAllowToolCall(b ...bool) ReActLoopOption
func WithAllowToolCallGetter ¶
func WithAllowToolCallGetter(allowToolCall func() bool) ReActLoopOption
func WithAllowUserInteract ¶
func WithAllowUserInteract(b ...bool) ReActLoopOption
func WithInitTask ¶
func WithInitTask(initHandler func(loop *ReActLoop, task aicommon.AIStatefulTask) error) ReActLoopOption
func WithLoopPromptGenerator ¶
func WithLoopPromptGenerator(generator ReActLoopCoreGenerateCode) ReActLoopOption
func WithMaxIterations ¶
func WithMaxIterations(maxIterations int) ReActLoopOption
func WithMemoryPool ¶
func WithMemoryPool(pool *omap.OrderedMap[string, *aimem.MemoryEntity]) ReActLoopOption
func WithMemorySizeLimit ¶
func WithMemorySizeLimit(sizeLimit int) ReActLoopOption
func WithMemoryTriage ¶
func WithMemoryTriage(triage aimem.MemoryTriage) ReActLoopOption
func WithOnAsyncTaskFinished ¶
func WithOnAsyncTaskFinished(fn func(task aicommon.AIStatefulTask)) ReActLoopOption
func WithOnAsyncTaskTrigger ¶
func WithOnAsyncTaskTrigger(fn func(i *LoopAction, task aicommon.AIStatefulTask)) ReActLoopOption
func WithOnPostIteraction ¶
func WithOnPostIteraction(fn func(loop *ReActLoop, iteration int, task aicommon.AIStatefulTask, isDone bool, reason any)) ReActLoopOption
WithOnPostIteraction sets a callback function that is called after each iteration of the ReAct loop.
func WithOnTaskCreated ¶
func WithOnTaskCreated(fn func(task aicommon.AIStatefulTask)) ReActLoopOption
func WithPersistentContextProvider ¶
func WithPersistentContextProvider(provider ContextProviderFunc) ReActLoopOption
func WithPersistentInstruction ¶
func WithPersistentInstruction(instruction string) ReActLoopOption
func WithReactiveDataBuilder ¶
func WithReactiveDataBuilder(provider FeedbackProviderFunc) ReActLoopOption
func WithReflectionOutputExample ¶
func WithReflectionOutputExample(example string) ReActLoopOption
func WithReflectionOutputExampleContextProvider ¶
func WithReflectionOutputExampleContextProvider(provider ContextProviderFunc) ReActLoopOption
func WithRegisterLoopAction ¶
func WithRegisterLoopAction(actionName string, desc string, opts []aitool.ToolOption, verifier LoopActionVerifierFunc, handler LoopActionHandlerFunc) ReActLoopOption
func WithRegisterLoopActionWithStreamField ¶
func WithRegisterLoopActionWithStreamField(actionName string, desc string, opts []aitool.ToolOption, fields []*LoopStreamField, verifier LoopActionVerifierFunc, handler LoopActionHandlerFunc) ReActLoopOption
func WithToolsGetter ¶
func WithToolsGetter(getter func() []*aitool.Tool) ReActLoopOption
func WithUserInteractGetter ¶
func WithUserInteractGetter(allowUserInteract func() bool) ReActLoopOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.