Documentation
¶
Index ¶
- type Agent
- func (a *Agent) AddFunctionTool(name, description string, fn interface{}) *Agent
- func (a *Agent) AddToolFromDefinition(definition map[string]interface{}, ...) *Agent
- func (a *Agent) AddToolsFromDefinitions(definitions []map[string]interface{}, ...) *Agent
- func (a *Agent) AsTaskDelegator() *Agent
- func (a *Agent) AsTaskExecutor() *Agent
- func (a *Agent) AsTool(toolName, toolDescription string) tool.Tool
- func (a *Agent) Clone(overrides map[string]interface{}) *Agent
- func (a *Agent) SetModelProvider(provider model.Provider) *Agent
- func (a *Agent) SetSystemInstructions(instructions string) *Agent
- func (a *Agent) WithBidirectionalHandoffs(agents ...*Agent) *Agent
- func (a *Agent) WithHandoffs(handoffs ...*Agent) *Agent
- func (a *Agent) WithHooks(hooks Hooks) *Agent
- func (a *Agent) WithModel(model interface{}) *Agent
- func (a *Agent) WithModelSettings(settings *model.Settings) *Agent
- func (a *Agent) WithOutputType(outputType interface{}) *Agent
- func (a *Agent) WithTools(tools ...tool.Tool) *Agent
- type DefaultAgentHooks
- func (h *DefaultAgentHooks) OnAfterHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent, result interface{}) error
- func (h *DefaultAgentHooks) OnAfterModelCall(ctx context.Context, agent *Agent, response *model.Response) error
- func (h *DefaultAgentHooks) OnAfterToolCall(ctx context.Context, agent *Agent, tool tool.Tool, result interface{}, ...) error
- func (h *DefaultAgentHooks) OnAgentEnd(ctx context.Context, agent *Agent, result interface{}) error
- func (h *DefaultAgentHooks) OnAgentStart(ctx context.Context, agent *Agent, input interface{}) error
- func (h *DefaultAgentHooks) OnBeforeHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent) error
- func (h *DefaultAgentHooks) OnBeforeModelCall(ctx context.Context, agent *Agent, request *model.Request) error
- func (h *DefaultAgentHooks) OnBeforeToolCall(ctx context.Context, agent *Agent, tool tool.Tool, ...) error
- type Hooks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// Core properties
Name string
Instructions string
Description string
// Model configuration
Model interface{} // Can be a string (model name) or a Model instance
ModelSettings *model.Settings
// Capabilities
Tools []tool.Tool
Handoffs []*Agent
// Output configuration
OutputType reflect.Type
// Lifecycle hooks
Hooks Hooks
// contains filtered or unexported fields
}
Agent represents an AI agent with specific configuration
func (*Agent) AddFunctionTool ¶
AddFunctionTool adds a function as a tool to the agent
func (*Agent) AddToolFromDefinition ¶
func (a *Agent) AddToolFromDefinition(definition map[string]interface{}, executeFn func(map[string]interface{}) (interface{}, error)) *Agent
AddToolFromDefinition adds a tool from an OpenAI-compatible tool definition
func (*Agent) AddToolsFromDefinitions ¶
func (a *Agent) AddToolsFromDefinitions(definitions []map[string]interface{}, executeFns map[string]func(map[string]interface{}) (interface{}, error)) *Agent
AddToolsFromDefinitions adds multiple tools from OpenAI-compatible tool definitions
func (*Agent) AsTaskDelegator ¶
AsTaskDelegator configures this agent as a task delegator with bidirectional flow support
func (*Agent) AsTaskExecutor ¶
AsTaskExecutor configures this agent as a task executor with bidirectional flow support
func (*Agent) SetModelProvider ¶
SetModelProvider sets the model provider for the agent
func (*Agent) SetSystemInstructions ¶
SetSystemInstructions sets the system instructions for the agent
func (*Agent) WithBidirectionalHandoffs ¶
WithBidirectionalHandoffs adds agents as handoffs with bidirectional flow support
func (*Agent) WithHandoffs ¶
WithHandoffs adds handoffs to the agent
func (*Agent) WithModelSettings ¶
WithModelSettings sets the model settings for the agent
func (*Agent) WithOutputType ¶
WithOutputType sets the output type for the agent
type DefaultAgentHooks ¶
type DefaultAgentHooks struct{}
DefaultAgentHooks provides a default implementation of Hooks
func (*DefaultAgentHooks) OnAfterHandoff ¶
func (h *DefaultAgentHooks) OnAfterHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent, result interface{}) error
OnAfterHandoff is called after a handoff to another agent
func (*DefaultAgentHooks) OnAfterModelCall ¶
func (h *DefaultAgentHooks) OnAfterModelCall(ctx context.Context, agent *Agent, response *model.Response) error
OnAfterModelCall is called after the model is called
func (*DefaultAgentHooks) OnAfterToolCall ¶
func (h *DefaultAgentHooks) OnAfterToolCall(ctx context.Context, agent *Agent, tool tool.Tool, result interface{}, err error) error
OnAfterToolCall is called after a tool is called
func (*DefaultAgentHooks) OnAgentEnd ¶
func (h *DefaultAgentHooks) OnAgentEnd(ctx context.Context, agent *Agent, result interface{}) error
OnAgentEnd is called when the agent finishes processing
func (*DefaultAgentHooks) OnAgentStart ¶
func (h *DefaultAgentHooks) OnAgentStart(ctx context.Context, agent *Agent, input interface{}) error
OnAgentStart is called when the agent starts processing
func (*DefaultAgentHooks) OnBeforeHandoff ¶
func (h *DefaultAgentHooks) OnBeforeHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent) error
OnBeforeHandoff is called before a handoff to another agent
func (*DefaultAgentHooks) OnBeforeModelCall ¶
func (h *DefaultAgentHooks) OnBeforeModelCall(ctx context.Context, agent *Agent, request *model.Request) error
OnBeforeModelCall is called before the model is called
func (*DefaultAgentHooks) OnBeforeToolCall ¶
func (h *DefaultAgentHooks) OnBeforeToolCall(ctx context.Context, agent *Agent, tool tool.Tool, params map[string]interface{}) error
OnBeforeToolCall is called before a tool is called
type Hooks ¶
type Hooks interface {
// OnAgentStart is called when the agent starts processing
OnAgentStart(ctx context.Context, agent *Agent, input interface{}) error
// OnBeforeModelCall is called before the model is called
OnBeforeModelCall(ctx context.Context, agent *Agent, request *model.Request) error
// OnAfterModelCall is called after the model is called
OnAfterModelCall(ctx context.Context, agent *Agent, response *model.Response) error
// OnBeforeToolCall is called before a tool is called
OnBeforeToolCall(ctx context.Context, agent *Agent, tool tool.Tool, params map[string]interface{}) error
// OnAfterToolCall is called after a tool is called
OnAfterToolCall(ctx context.Context, agent *Agent, tool tool.Tool, result interface{}, err error) error
// OnBeforeHandoff is called before a handoff to another agent
OnBeforeHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent) error
// OnAfterHandoff is called after a handoff to another agent
OnAfterHandoff(ctx context.Context, agent *Agent, handoffAgent *Agent, result interface{}) error
// OnAgentEnd is called when the agent finishes processing
OnAgentEnd(ctx context.Context, agent *Agent, result interface{}) error
}
Hooks defines lifecycle hooks for an agent