Documentation ¶
Overview ¶
Package agent provides functionality for creating and managing agents that leverage Large Language Models (LLMs) to make informed decisions and take actions.
Index ¶
- Constants
- Variables
- type ConversationalReactDescription
- type ConversationalReactDescriptionOptions
- type Executor
- func NewConversationalReactDescription(llm schema.Model, tools []schema.Tool, ...) (*Executor, error)
- func NewExecutor(agent schema.Agent, tools []schema.Tool, optFns ...func(o *ExecutorOptions)) (*Executor, error)
- func NewOpenAIFunctions(model schema.ChatModel, tools []schema.Tool, ...) (*Executor, error)
- func NewReactDescription(llm schema.Model, tools []schema.Tool, ...) (*Executor, error)
- func (e Executor) Call(ctx context.Context, inputs schema.ChainValues, ...) (schema.ChainValues, error)
- func (e Executor) Callbacks() []schema.Callback
- func (e Executor) InputKeys() []string
- func (e Executor) Memory() schema.Memory
- func (e Executor) OutputKeys() []string
- func (e Executor) Type() string
- func (e Executor) Verbose() bool
- type ExecutorOptions
- type OpenAIFunctions
- type OpenAIFunctionsOptions
- type ReactDescription
- type ReactDescriptionOptions
Constants ¶
const DefaultMaxIterations = 5
Variables ¶
var ( ErrAgentNoReturn = errors.New("no actions or finish was returned by the agent") ErrNotFinished = errors.New("agent not finished before max iterations") ErrInvalidChainReturnType = errors.New("agent chain did not return a string") ErrUnableToParseOutput = errors.New("unable to parse agent output") )
Functions ¶
This section is empty.
Types ¶
type ConversationalReactDescription ¶ added in v0.0.15
type ConversationalReactDescription struct {
// contains filtered or unexported fields
}
func (*ConversationalReactDescription) InputKeys ¶ added in v0.0.15
func (a *ConversationalReactDescription) InputKeys() []string
func (*ConversationalReactDescription) OutputKeys ¶ added in v0.0.15
func (a *ConversationalReactDescription) OutputKeys() []string
func (*ConversationalReactDescription) Plan ¶ added in v0.0.15
func (a *ConversationalReactDescription) Plan(ctx context.Context, intermediateSteps []schema.AgentStep, inputs schema.ChainValues) ([]*schema.AgentAction, *schema.AgentFinish, error)
type ConversationalReactDescriptionOptions ¶ added in v0.0.15
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor represents an agent executor that executes a chain of actions based on inputs and a defined agent model.
func NewConversationalReactDescription ¶ added in v0.0.15
func NewExecutor ¶
func NewExecutor(agent schema.Agent, tools []schema.Tool, optFns ...func(o *ExecutorOptions)) (*Executor, error)
NewExecutor creates a new instance of the Executor with the given agent and a list of available tools.
func NewOpenAIFunctions ¶ added in v0.0.27
func NewOpenAIFunctions(model schema.ChatModel, tools []schema.Tool, optFns ...func(o *OpenAIFunctionsOptions)) (*Executor, error)
NewOpenAIFunctions creates a new instance of the OpenAIFunctions agent with the given model and tools. It returns an error if the model is not an OpenAI chatModel or fails to convert tools to function definitions.
func NewReactDescription ¶ added in v0.0.24
func (Executor) Call ¶ added in v0.0.4
func (e Executor) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)
Call executes the AgentExecutor chain with the given context and inputs. It returns the outputs of the chain or an error, if any.
func (Executor) Callbacks ¶ added in v0.0.13
Callbacks returns the callbacks associated with the chain.
func (Executor) OutputKeys ¶
OutputKeys returns the output keys the chain will return.
type ExecutorOptions ¶ added in v0.0.4
type ExecutorOptions struct { *schema.CallbackOptions MaxIterations int Memory schema.Memory AgentChainType string }
ExecutorOptions holds configuration options for the Executor.
type OpenAIFunctions ¶ added in v0.0.27
type OpenAIFunctions struct {
// contains filtered or unexported fields
}
OpenAIFunctions is an agent that uses OpenAI chatModels and schema.Tools to perform actions.
func (*OpenAIFunctions) InputKeys ¶ added in v0.0.27
func (a *OpenAIFunctions) InputKeys() []string
InputKeys returns the expected input keys for the agent.
func (*OpenAIFunctions) OutputKeys ¶ added in v0.0.27
func (a *OpenAIFunctions) OutputKeys() []string
OutputKeys returns the output keys that the agent will return.
func (*OpenAIFunctions) Plan ¶ added in v0.0.27
func (a *OpenAIFunctions) Plan(ctx context.Context, intermediateSteps []schema.AgentStep, inputs schema.ChainValues) ([]*schema.AgentAction, *schema.AgentFinish, error)
Plan executes the agent with the given context, intermediate steps, and inputs. It returns the agent actions, agent finish, or an error, if any.
type OpenAIFunctionsOptions ¶ added in v0.0.27
type OpenAIFunctionsOptions struct { *schema.CallbackOptions // OutputKey is the key to store the output of the agent in the ChainValues. OutputKey string SystemMessage *prompt.SystemMessageTemplate ExtraMessages []prompt.MessageTemplate MaxIterations int }
OpenAIFunctionsOptions represents the configuration options for the OpenAIFunctions agent.
type ReactDescription ¶ added in v0.0.24
type ReactDescription struct {
// contains filtered or unexported fields
}
func (*ReactDescription) InputKeys ¶ added in v0.0.24
func (a *ReactDescription) InputKeys() []string
func (*ReactDescription) OutputKeys ¶ added in v0.0.24
func (a *ReactDescription) OutputKeys() []string
func (*ReactDescription) Plan ¶ added in v0.0.24
func (a *ReactDescription) Plan(ctx context.Context, intermediateSteps []schema.AgentStep, inputs schema.ChainValues) ([]*schema.AgentAction, *schema.AgentFinish, error)