Documentation
¶
Overview ¶
Package agents include BaseAgent
Index ¶
- type Agent
- func (a *Agent[I, O]) AddToMemory(msg *components.Message)
- func (a *Agent[I, O]) ClearMemory()
- func (a *Agent[I, O]) Client() instructor.Instructor
- func (a *Agent[I, O]) Encoder() instructor.Encoder
- func (a *Agent[I, O]) Memory() components.MemoryStore
- func (a *Agent[I, O]) Model() string
- 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.LLMResponse) error
- func (a *Agent[I, O]) RunAnonymous(ctx context.Context, userInput any, apiResp *components.LLMResponse) (any, error)
- func (a *Agent[I, O]) SchemaStream(ctx context.Context, userInput *I) (<-chan any, <-chan instructor.StreamData, MergeResponse, 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.LLMResponse))
- func (a *Agent[I, O]) SetErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.LLMResponse, error))
- func (a *Agent[I, O]) SetMaxTokens(maxTokens int)
- func (a *Agent[I, O]) SetMemory(m components.MemoryStore)
- 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 float64)
- func (a *Agent[I, O]) SetTopK(topK int)
- func (a *Agent[I, O]) SetTopP(topP float64)
- func (a *Agent[I, O]) Stream(ctx context.Context, userInput *I) (<-chan instructor.StreamData, MergeResponse, error)
- func (a *Agent[I, O]) StreamAnonymous(ctx context.Context, userInput any) (<-chan instructor.StreamData, MergeResponse, error)
- 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 AnonymousAgent
- type AnonymousStreamableAgent
- type Chain
- func (c *Chain[I, O]) Name() string
- func (c *Chain[I, O]) Run(ctx context.Context, input *I, output *O) ([]components.LLMResponse, error)
- func (c *Chain[I, O]) RunAnonymous(ctx context.Context, input any, apiResp *components.LLMResponse) (any, error)
- func (c *Chain[I, O]) SetEndHook(fn func(context.Context, *Chain[I, O], *I, *O, []components.LLMResponse))
- func (c *Chain[I, O]) SetErrorHook(fn func(context.Context, *Chain[I, O], *I, []components.LLMResponse, error))
- func (c *Chain[I, O]) SetName(name string)
- func (c *Chain[I, O]) SetStartHook(fn func(context.Context, *Chain[I, O], *I))
- type Config
- type IAgent
- type MergeResponse
- type Option
- func WithClient(clt instructor.Instructor) Option
- func WithMaxTokens(maxTokens int) Option
- func WithMemory(m components.MemoryStore) Option
- func WithModel(model string) Option
- func WithName(name string) Option
- func WithSystemPromptGenerator(g systemprompt.Generator) Option
- func WithTemperature(temperature float64) Option
- func WithTopK(topK int) Option
- func WithTopP(topP float64) 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.LLMResponse) error
- func (a *OrchestrationAgent[I, O]) RunAnonymous(ctx context.Context, input any, apiResp *components.LLMResponse) (any, error)
- func (a *OrchestrationAgent[I, O]) SetName(name string)
- type StreamableAgent
- 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.LLMResponse) error
- func (t *ToolAgent[I, T, O]) RunAnonymous(ctx context.Context, userInput any, apiResp *components.LLMResponse) (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.LLMResponse))
- func (t *ToolAgent[I, T, O]) SetEndAgentErrorHook(fn func(context.Context, *Agent[I, O], *I, *components.LLMResponse, 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.LLMResponse))
- 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.LLMResponse))
- func (t *ToolAgent[I, T, O]) SetStartAgentErrorHook(fn func(context.Context, *Agent[I, T], *I, *components.LLMResponse, 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 float64)
- 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))
- func (t *ToolAgent[I, T, O]) SetTopK(topK int)
- func (t *ToolAgent[I, T, O]) SetTopP(topP float64)
- type TypeableAgent
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]) AddToMemory ¶ added in v1.2.3
func (a *Agent[I, O]) AddToMemory(msg *components.Message)
AddToMemory add message to memory
func (*Agent[I, O]) ClearMemory ¶ added in v1.1.9
func (a *Agent[I, O]) ClearMemory()
ClearMemory resets the memory to its initial state
func (*Agent[I, O]) Client ¶ added in v1.3.2
func (a *Agent[I, O]) Client() instructor.Instructor
func (*Agent[I, O]) Encoder ¶ added in v1.3.8
func (a *Agent[I, O]) Encoder() instructor.Encoder
func (*Agent[I, O]) Memory ¶ added in v1.2.3
func (a *Agent[I, O]) Memory() components.MemoryStore
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.LLMResponse) error
Run runs the chat agent with the given user input synchronously.
func (*Agent[I, O]) RunAnonymous ¶ added in v1.1.8
func (a *Agent[I, O]) RunAnonymous(ctx context.Context, userInput any, apiResp *components.LLMResponse) (any, error)
Run runs the chat agent with the given user input for chain.
func (*Agent[I, O]) SchemaStream ¶ added in v1.3.1
func (a *Agent[I, O]) SchemaStream(ctx context.Context, userInput *I) (<-chan any, <-chan instructor.StreamData, MergeResponse, error)
Run runs the chat agent with the given user input synchronously.
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.LLMResponse))
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.LLMResponse, error))
func (*Agent[I, O]) SetMaxTokens ¶
func (*Agent[I, O]) SetMemory ¶
func (a *Agent[I, O]) SetMemory(m components.MemoryStore)
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]) Stream ¶ added in v1.1.0
func (a *Agent[I, O]) Stream(ctx context.Context, userInput *I) (<-chan instructor.StreamData, MergeResponse, error)
Run runs the chat agent with the given user input synchronously.
func (*Agent[I, O]) StreamAnonymous ¶ added in v1.1.8
func (a *Agent[I, O]) StreamAnonymous(ctx context.Context, userInput any) (<-chan instructor.StreamData, MergeResponse, error)
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) (AnonymousAgent, any, error)
AgentSelector will returns a Tool based on input param
type AgentSetter ¶
type AgentSetter interface {
SetClient(instructor.Instructor)
SetMemory(components.MemoryStore)
SetSystemPromptGenerator(systemprompt.Generator)
SetModel(string)
SetTemperature(float64)
SetTopP(float64)
SetTopK(int)
SetMaxTokens(int)
}
type AnonymousAgent ¶ added in v1.1.8
type AnonymousAgent interface {
IAgent
RunAnonymous(context.Context, any, *components.LLMResponse) (any, error)
}
type AnonymousStreamableAgent ¶ added in v1.1.8
type AnonymousStreamableAgent interface {
AnonymousAgent
StreamAnonymous(context.Context, any) (<-chan instructor.StreamData, MergeResponse, error)
}
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.LLMResponse, error)
Run runs the chat agents with the given user input synchronously.
func (*Chain[I, O]) RunAnonymous ¶ added in v1.1.8
func (c *Chain[I, O]) RunAnonymous(ctx context.Context, input any, apiResp *components.LLMResponse) (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.LLMResponse))
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.LLMResponse, error))
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents general agents configuration
type MergeResponse ¶ added in v1.1.0
type MergeResponse = func(*components.LLMResponse)
type Option ¶
type Option func(a *Config)
func WithClient ¶
func WithClient(clt instructor.Instructor) Option
func WithMaxTokens ¶
func WithMemory ¶
func WithMemory(m components.MemoryStore) 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.LLMResponse) error
func (*OrchestrationAgent[I, O]) RunAnonymous ¶ added in v1.1.8
func (a *OrchestrationAgent[I, O]) RunAnonymous(ctx context.Context, input any, apiResp *components.LLMResponse) (any, error)
func (*OrchestrationAgent[I, O]) SetName ¶ added in v1.0.8
func (a *OrchestrationAgent[I, O]) SetName(name string)
type StreamableAgent ¶ added in v1.1.8
type StreamableAgent[I schema.Schema, O schema.Schema] interface { IAgent Stream(context.Context, *I) (<-chan instructor.StreamData, MergeResponse, error) }
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.LLMResponse) error
Run runs the chat agent with the given user input synchronously.
func (*ToolAgent[I, T, O]) RunAnonymous ¶ added in v1.1.8
func (t *ToolAgent[I, T, O]) RunAnonymous(ctx context.Context, userInput any, apiResp *components.LLMResponse) (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.LLMResponse))
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.LLMResponse, 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.LLMResponse))
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.LLMResponse, 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.LLMResponse))
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.LLMResponse, 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]
func (*ToolAgent[I, T, O]) SetToolEndHook ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetToolErrorHook ¶ added in v1.0.8
func (*ToolAgent[I, T, O]) SetToolStartHook ¶ added in v1.0.8
type TypeableAgent ¶ added in v1.1.8
type TypeableAgent[I schema.Schema, O schema.Schema] interface { IAgent Run(context.Context, *I, *O, *components.LLMResponse) error }