Documentation
¶
Overview ¶
Package agents include BaseAgent
Index ¶
- type Agent
- func (a Agent[I, O]) Name() string
- func (a *Agent[I, O]) NewMessage(role components.MessageRole, content schema.Schema) *components.Message
- func (a *Agent[I, O]) RegisterSystemPromptContextProvider(provider systemprompt.ContextProvider)
- func (a *Agent[I, O]) ResetMemory()
- func (a *Agent[I, O]) Run(ctx context.Context, userInput *I, output *O, apiResp *components.ApiResponse) error
- func (a *Agent[I, O]) RunForChain(ctx context.Context, userInput any, apiResp *components.ApiResponse) (any, error)
- func (a *Agent[I, O]) SetClient(clt instructor.Instructor)
- func (a *Agent[I, O]) SetEndHook(fn func(context.Context, *Agent[I, O], *I, *O, *components.ApiResponse))
- func (a *Agent[I, O]) SetErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.ApiResponse, error))
- func (a *Agent[I, O]) SetMaxTokens(maxTokens int)
- func (a *Agent[I, O]) SetMemory(m *components.Memory)
- func (a *Agent[I, O]) SetModel(model string)
- func (a *Agent[I, O]) SetName(name string)
- func (a *Agent[I, O]) SetStartHook(fn func(context.Context, *Agent[I, O], *I))
- func (a *Agent[I, O]) SetSystemPromptGenerator(g systemprompt.Generator)
- func (a *Agent[I, O]) SetTemperature(temperature float32)
- func (a *Agent[I, O]) SystemPrompt() string
- func (a *Agent[I, O]) SystemPromptContextProvider(title string) (systemprompt.ContextProvider, error)
- func (a *Agent[I, O]) UnregisterSystemPromptContextProvider(title string)
- type AgentSelector
- type AgentSetter
- type Chain
- func (c *Chain[I, O]) Name() string
- func (c *Chain[I, O]) Run(ctx context.Context, input *I, output *O) ([]components.ApiResponse, error)
- func (c *Chain[I, O]) RunForChain(ctx context.Context, input any, apiResp *components.ApiResponse) (any, error)
- func (c *Chain[I, O]) SetEndHook(fn func(context.Context, *Chain[I, O], *I, *O, []components.ApiResponse))
- func (c *Chain[I, O]) SetErrorHook(fn func(context.Context, *Chain[I, O], *I, []components.ApiResponse, error))
- func (c *Chain[I, O]) SetName(name string)
- func (c *Chain[I, O]) SetStartHook(fn func(context.Context, *Chain[I, O], *I))
- type ChainableAgent
- type Config
- type IAgent
- type Option
- func WithClient(clt instructor.Instructor) Option
- func WithMaxTokens(maxTokens int) Option
- func WithMemory(m *components.Memory) Option
- func WithModel(model string) Option
- func WithName(name string) Option
- func WithSystemPromptGenerator(g systemprompt.Generator) Option
- func WithTemperature(temperature float32) Option
- type OrchestrationAgent
- func (a *OrchestrationAgent[I, O]) Name() string
- func (a *OrchestrationAgent[I, O]) Run(ctx context.Context, input *I, output *O, apiResp *components.ApiResponse) error
- func (a *OrchestrationAgent[I, O]) RunForChain(ctx context.Context, input any, apiResp *components.ApiResponse) (any, error)
- func (a *OrchestrationAgent[I, O]) SetName(name string)
- type ToolAgent
- func (t *ToolAgent[I, T, O]) Name() string
- func (t *ToolAgent[I, T, O]) ResetMemory()
- func (t *ToolAgent[I, T, O]) Run(ctx context.Context, userInput *I, output *O, apiResp *components.ApiResponse) error
- func (t *ToolAgent[I, T, O]) RunForChain(ctx context.Context, userInput any, apiResp *components.ApiResponse) (any, error)
- func (t *ToolAgent[I, T, O]) SetClient(clt instructor.Instructor)
- func (t *ToolAgent[I, T, O]) SetEndAgentEndHook(fn func(context.Context, *Agent[I, O], *I, *O, *components.ApiResponse))
- func (t *ToolAgent[I, T, O]) SetEndAgentErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.ApiResponse, error))
- func (t *ToolAgent[I, T, O]) SetEndAgentName(name string)
- func (t *ToolAgent[I, T, O]) SetEndAgentStartHook(fn func(context.Context, *Agent[I, O], *I))
- func (t *ToolAgent[I, T, O]) SetEndHook(fn func(context.Context, *ToolAgent[I, T, O], *I, *O, *components.ApiResponse))
- func (t *ToolAgent[I, T, O]) SetErrorHook(...)
- func (t *ToolAgent[I, T, O]) SetMaxTokens(maxTokens int)
- func (t *ToolAgent[I, T, O]) SetMemory(m *components.Memory)
- func (t *ToolAgent[I, T, O]) SetModel(model string)
- func (t *ToolAgent[I, T, O]) SetName(name string)
- func (t *ToolAgent[I, T, O]) SetStartAgentEndHook(fn func(context.Context, *Agent[I, T], *I, *T, *components.ApiResponse))
- func (t *ToolAgent[I, T, O]) SetStartAgentErrorHook(fn func(context.Context, *Agent[I, T], *I, *components.ApiResponse, error))
- func (t *ToolAgent[I, T, O]) SetStartAgentName(name string)
- func (t *ToolAgent[I, T, O]) SetStartAgentStartHook(fn func(context.Context, *Agent[I, T], *I))
- func (t *ToolAgent[I, T, O]) SetStartHook(fn func(context.Context, *ToolAgent[I, T, O], *I))
- func (t *ToolAgent[I, T, O]) SetSystemPromptGenerator(g systemprompt.Generator)
- func (t *ToolAgent[I, T, O]) SetTemperature(temperature float32)
- func (t *ToolAgent[I, T, O]) SetTool(tool tools.AnonymousTool) *ToolAgent[I, T, O]
- func (t *ToolAgent[I, T, O]) SetToolEndHook(fn func(context.Context, tools.AnonymousTool, any, any))
- func (t *ToolAgent[I, T, O]) SetToolErrorHook(fn func(context.Context, tools.AnonymousTool, any, error))
- func (t *ToolAgent[I, T, O]) SetToolStartHook(fn func(context.Context, tools.AnonymousTool, any))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent[I schema.Schema, O schema.Schema] struct { Config // contains filtered or unexported fields }
Agent class for chat agents. This class provides the core functionality for handling chat interactions, including managing memory, generating system prompts, and obtaining responses from a language model.
func (*Agent[I, O]) NewMessage ¶ added in v1.0.8
func (a *Agent[I, O]) NewMessage(role components.MessageRole, content schema.Schema) *components.Message
func (*Agent[I, O]) RegisterSystemPromptContextProvider ¶
func (a *Agent[I, O]) RegisterSystemPromptContextProvider(provider systemprompt.ContextProvider)
RegisterSystemPromptContextProvider registers a new context provider
func (*Agent[I, O]) ResetMemory ¶
func (a *Agent[I, O]) ResetMemory()
ResetMemory resets the memory to its initial state
func (*Agent[I, O]) Run ¶
func (a *Agent[I, O]) Run(ctx context.Context, userInput *I, output *O, apiResp *components.ApiResponse) error
Run runs the chat agent with the given user input synchronously.
func (*Agent[I, O]) RunForChain ¶ added in v1.0.8
func (a *Agent[I, O]) RunForChain(ctx context.Context, userInput any, apiResp *components.ApiResponse) (any, error)
Run runs the chat agent with the given user input for chain.
func (*Agent[I, O]) SetClient ¶
func (a *Agent[I, O]) SetClient(clt instructor.Instructor)
func (*Agent[I, O]) SetEndHook ¶ added in v1.0.8
func (a *Agent[I, O]) SetEndHook(fn func(context.Context, *Agent[I, O], *I, *O, *components.ApiResponse))
func (*Agent[I, O]) SetErrorHook ¶ added in v1.0.8
func (a *Agent[I, O]) SetErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.ApiResponse, error))
func (*Agent[I, O]) SetMaxTokens ¶
func (*Agent[I, O]) SetMemory ¶
func (a *Agent[I, O]) SetMemory(m *components.Memory)
func (*Agent[I, O]) SetStartHook ¶ added in v1.0.8
func (*Agent[I, O]) SetSystemPromptGenerator ¶
func (a *Agent[I, O]) SetSystemPromptGenerator(g systemprompt.Generator)
func (*Agent[I, O]) SetTemperature ¶
func (*Agent[I, O]) SystemPrompt ¶
SystemPrompt returns the system prompt
func (*Agent[I, O]) SystemPromptContextProvider ¶
func (a *Agent[I, O]) SystemPromptContextProvider(title string) (systemprompt.ContextProvider, error)
SystemPromptContextProvider returns agent systemPromptGenerator's context provider
func (*Agent[I, O]) UnregisterSystemPromptContextProvider ¶
RegisterSystemPromptContextProvider Unregisters an existing context provider.
type AgentSelector ¶ added in v1.0.8
type AgentSelector[I schema.Schema] func(req *I) (ChainableAgent, any, error)
AgentSelector will returns a Tool based on input param
type AgentSetter ¶
type AgentSetter interface {
SetClient(clt instructor.Instructor)
SetMemory(m *components.Memory)
SetSystemPromptGenerator(g *systemprompt.Generator)
SetModel(model string)
SetTemperature(temperature float32)
SetMaxTokens(maxTokens int)
}
type Chain ¶ added in v1.0.8
Chain agents chain
func (*Chain[I, O]) Run ¶ added in v1.0.8
func (c *Chain[I, O]) Run(ctx context.Context, input *I, output *O) ([]components.ApiResponse, error)
Run runs the chat agents with the given user input synchronously.
func (*Chain[I, O]) RunForChain ¶ added in v1.0.8
func (c *Chain[I, O]) RunForChain(ctx context.Context, input any, apiResp *components.ApiResponse) (any, error)
Run runs the chat agents with the given user input synchronously.
func (*Chain[I, O]) SetEndHook ¶ added in v1.0.8
func (c *Chain[I, O]) SetEndHook(fn func(context.Context, *Chain[I, O], *I, *O, []components.ApiResponse))
func (*Chain[I, O]) SetErrorHook ¶ added in v1.0.8
func (c *Chain[I, O]) SetErrorHook(fn func(context.Context, *Chain[I, O], *I, []components.ApiResponse, error))
type ChainableAgent ¶ added in v1.0.8
type ChainableAgent interface {
IAgent
RunForChain(context.Context, any, *components.ApiResponse) (any, error)
}
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents general agents configuration
type Option ¶
type Option func(a *Config)
func WithClient ¶
func WithClient(clt instructor.Instructor) Option
func WithMaxTokens ¶
func WithMemory ¶
func WithMemory(m *components.Memory) Option
func WithSystemPromptGenerator ¶
func WithSystemPromptGenerator(g systemprompt.Generator) Option
func WithTemperature ¶
type OrchestrationAgent ¶ added in v1.0.8
type OrchestrationAgent[I schema.Schema, O schema.Schema] struct { // contains filtered or unexported fields }
OrchestrationAgent is an agent for orchestration
func NewOrchestrationAgent ¶ added in v1.0.8
func NewOrchestrationAgent[I schema.Schema, O schema.Schema](selector AgentSelector[I]) *OrchestrationAgent[I, O]
func (*OrchestrationAgent[I, O]) Name ¶ added in v1.0.8
func (a *OrchestrationAgent[I, O]) Name() string
func (*OrchestrationAgent[I, O]) Run ¶ added in v1.0.8
func (a *OrchestrationAgent[I, O]) Run(ctx context.Context, input *I, output *O, apiResp *components.ApiResponse) error
func (*OrchestrationAgent[I, O]) RunForChain ¶ added in v1.0.8
func (a *OrchestrationAgent[I, O]) RunForChain(ctx context.Context, input any, apiResp *components.ApiResponse) (any, error)
func (*OrchestrationAgent[I, O]) SetName ¶ added in v1.0.8
func (a *OrchestrationAgent[I, O]) SetName(name string)
type ToolAgent ¶ added in v1.0.8
type ToolAgent[I schema.Schema, T schema.Schema, O schema.Schema] struct { // contains filtered or unexported fields }
ToolAgent represent agent with tool callback
func NewToolAgent ¶ added in v1.0.8
func NewToolAgent[I schema.Schema, T schema.Schema, O schema.Schema](options ...Option) *ToolAgent[I, T, O]
NewToolAgent returns a new ToolAgent instance
func (*ToolAgent[I, T, O]) ResetMemory ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) ResetMemory()
func (*ToolAgent[I, T, O]) Run ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) Run(ctx context.Context, userInput *I, output *O, apiResp *components.ApiResponse) error
Run runs the chat agent with the given user input synchronously.
func (*ToolAgent[I, T, O]) RunForChain ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) RunForChain(ctx context.Context, userInput any, apiResp *components.ApiResponse) (any, error)
Run runs the chat agent with the given user input for chain.
func (*ToolAgent[I, T, O]) SetClient ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetClient(clt instructor.Instructor)
func (*ToolAgent[I, T, O]) SetEndAgentEndHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetEndAgentEndHook(fn func(context.Context, *Agent[I, O], *I, *O, *components.ApiResponse))
func (*ToolAgent[I, T, O]) SetEndAgentErrorHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetEndAgentErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.ApiResponse, error))
func (*ToolAgent[I, T, O]) SetEndAgentName ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetEndAgentStartHook ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetEndHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetEndHook(fn func(context.Context, *ToolAgent[I, T, O], *I, *O, *components.ApiResponse))
func (*ToolAgent[I, T, O]) SetErrorHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetErrorHook(fn func(context.Context, *ToolAgent[I, T, O], *I, *components.ApiResponse, error))
func (*ToolAgent[I, T, O]) SetMaxTokens ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetMemory ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetMemory(m *components.Memory)
func (*ToolAgent[I, T, O]) SetStartAgentEndHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetStartAgentEndHook(fn func(context.Context, *Agent[I, T], *I, *T, *components.ApiResponse))
func (*ToolAgent[I, T, O]) SetStartAgentErrorHook ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetStartAgentErrorHook(fn func(context.Context, *Agent[I, T], *I, *components.ApiResponse, error))
func (*ToolAgent[I, T, O]) SetStartAgentName ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetStartAgentStartHook ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetStartHook ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetSystemPromptGenerator ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetSystemPromptGenerator(g systemprompt.Generator)
func (*ToolAgent[I, T, O]) SetTemperature ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetTool ¶ added in v1.0.8
func (t *ToolAgent[I, T, O]) SetTool(tool tools.AnonymousTool) *ToolAgent[I, T, O]