Documentation ΒΆ
Index ΒΆ
- Variables
- func WithFunctionParameters(parameters ...string) opts.Option[AgentFunctionDefinition]
- type Agent
- type AgentFunctionDefinition
- type AgentFunctionOption
- type ContextVars
- type DefaultAgent
- func (a *DefaultAgent) AddFunction(f1 AgentFunctionDefinition, frest ...AgentFunctionDefinition)
- func (a *DefaultAgent) DisableParallelToolCalls()
- func (a *DefaultAgent) EnableParallelToolCalls()
- func (a *DefaultAgent) Functions() []AgentFunctionDefinition
- func (a *DefaultAgent) Instructions() string
- func (a *DefaultAgent) Model() string
- func (a *DefaultAgent) Name() string
- func (a *DefaultAgent) ParallelToolCalls() bool
- func (a *DefaultAgent) RenderInstructions(cv ContextVars) (string, error)
- func (a *DefaultAgent) SetToolChoice(toolChoice string)
- func (a *DefaultAgent) ToolChoice() string
- func (a *DefaultAgent) WithFunction(f1 AgentFunctionDefinition, frest ...AgentFunctionDefinition) *DefaultAgent
- func (a *DefaultAgent) WithParallelToolCalls() *DefaultAgent
- func (a *DefaultAgent) WithToolChoice(toolChoice string) *DefaultAgent
- func (a *DefaultAgent) WithoutParallelToolCalls() *DefaultAgent
Constants ΒΆ
This section is empty.
Variables ΒΆ
var WithFunctionDescription = opts.ForName[AgentFunctionDefinition, string]("Description")
WithFunctionDescription returns a function that sets the description of an agent function. It takes a string parameter 'description' and returns a function that modifies the 'Description' field of the provided 'agentFunctionOptions' struct.
var WithFunctionName = opts.ForName[AgentFunctionDefinition, string]("Name")
WithFunctionName returns a function that sets the Name field of agentFunctionOptions to the provided name. This can be used to configure an agent function with a specific name.
Parameters:
- name: A string representing the name to be assigned.
Returns:
- A function that takes a pointer to agentFunctionOptions and sets its Name field.
Functions ΒΆ
func WithFunctionParameters ΒΆ
func WithFunctionParameters(parameters ...string) opts.Option[AgentFunctionDefinition]
WithFunctionParameters returns a function that sets the Parameters field of agentFunctionOptions to a map where each parameter is assigned a key in the format "paramN", where N is the index of the parameter in the input slice.
Parameters:
parameters - a variadic string slice containing the parameters to be set.
Returns:
A function that takes a pointer to agentFunctionOptions and sets its Parameters field.
Types ΒΆ
type Agent ΒΆ
type Agent interface { // Name returns the agent's name Name() string // Model returns the agent's model Model() string // Instructions returns the agent's instructions Instructions() string // Functions returns the agent's function definitions Functions() []AgentFunctionDefinition // ToolChoice returns the agent's tool choice ToolChoice() string // ParallelToolCalls returns whether the agent supports parallel tool calls ParallelToolCalls() bool RenderInstructions(ContextVars) (string, error) }
Agent represents an interface for an agent with various capabilities. It provides methods to retrieve the agent's name, model, instructions, function definitions, tool choice, and whether it supports parallel tool calls. available functions, tool choice, and whether parallel tool calls are supported.
type AgentFunctionDefinition ΒΆ
type AgentFunctionDefinition struct { Name string Description string Parameters map[string]string Function any }
AgentFunctionDefinition represents the definition of an agent function. It includes the function's name, description, parameters, and the function itself.
func AgentFunction ΒΆ
func AgentFunction(f any, options ...AgentFunctionOption) (AgentFunctionDefinition, error)
AgentFunction creates an AgentFunctionDefinition from the provided function and options. The function is assigned to the Function field of the resulting AgentFunctionDefinition.
Parameters:
- f: The function to be assigned to the AgentFunctionDefinition.
- options: A variadic list of AgentFunctionOption to configure the AgentFunctionDefinition.
Returns:
An AgentFunctionDefinition with the provided function and applied options.
func MustAgentFunction ΒΆ
func MustAgentFunction(f any, options ...AgentFunctionOption) AgentFunctionDefinition
MustAgentFunction wraps the AgentFunction call and ensures that any error returned by AgentFunction is handled by panicking. It takes a function `f` and a variadic number of AgentFunctionOption `options` as arguments, and returns an AgentFunctionDefinition. If AgentFunction returns an error, MustAgentFunction will panic.
Parameters:
- f: The function to be wrapped.
- options: A variadic number of options to configure the agent function.
Returns:
- AgentFunctionDefinition: The definition of the agent function.
type AgentFunctionOption ΒΆ
type AgentFunctionOption = opts.Option[AgentFunctionDefinition]
AgentFunctionOption is a type alias for a function that modifies the configuration options of an agent function. It allows for flexible and customizable configuration of agent functions by applying various options.
type ContextVars ΒΆ
func (ContextVars) String ΒΆ
func (cv ContextVars) String() string
type DefaultAgent ΒΆ
type DefaultAgent struct {
// contains filtered or unexported fields
}
DefaultAgent represents an agent with specific attributes and capabilities. It includes the agent's name, model, instructions, function definitions, tool choice, and whether it supports parallel tool calls.
func NewAgent ΒΆ
func NewAgent(name, model, instructions string) *DefaultAgent
NewAgent creates a new DefaultAgent with the provided parameters.
func (*DefaultAgent) AddFunction ΒΆ
func (a *DefaultAgent) AddFunction(f1 AgentFunctionDefinition, frest ...AgentFunctionDefinition)
AddFunction adds a function definition to the agent.
func (*DefaultAgent) DisableParallelToolCalls ΒΆ
func (a *DefaultAgent) DisableParallelToolCalls()
DisableParallelToolCalls disables parallel tool calls for the agent.
func (*DefaultAgent) EnableParallelToolCalls ΒΆ
func (a *DefaultAgent) EnableParallelToolCalls()
EnableParallelToolCalls enables parallel tool calls for the agent.
func (*DefaultAgent) Functions ΒΆ
func (a *DefaultAgent) Functions() []AgentFunctionDefinition
Functions returns the agent's function definitions.
func (*DefaultAgent) Instructions ΒΆ
func (a *DefaultAgent) Instructions() string
Instructions returns the agent's instructions.
func (*DefaultAgent) Model ΒΆ
func (a *DefaultAgent) Model() string
Model returns the agent's model.
func (*DefaultAgent) ParallelToolCalls ΒΆ
func (a *DefaultAgent) ParallelToolCalls() bool
ParallelToolCalls returns whether the agent supports parallel tool calls.
func (*DefaultAgent) RenderInstructions ΒΆ
func (a *DefaultAgent) RenderInstructions(cv ContextVars) (string, error)
func (*DefaultAgent) SetToolChoice ΒΆ
func (a *DefaultAgent) SetToolChoice(toolChoice string)
SetToolChoice sets the agent's tool choice.
func (*DefaultAgent) ToolChoice ΒΆ
func (a *DefaultAgent) ToolChoice() string
ToolChoice returns the agent's tool choice.
func (*DefaultAgent) WithFunction ΒΆ
func (a *DefaultAgent) WithFunction(f1 AgentFunctionDefinition, frest ...AgentFunctionDefinition) *DefaultAgent
WithFunction adds a function definition to the agent.
func (*DefaultAgent) WithParallelToolCalls ΒΆ
func (a *DefaultAgent) WithParallelToolCalls() *DefaultAgent
WithParallelToolCalls enables parallel tool calls for the agent.
func (*DefaultAgent) WithToolChoice ΒΆ
func (a *DefaultAgent) WithToolChoice(toolChoice string) *DefaultAgent
WithToolChoice sets the agent's tool choice.
func (*DefaultAgent) WithoutParallelToolCalls ΒΆ
func (a *DefaultAgent) WithoutParallelToolCalls() *DefaultAgent
WithoutParallelToolCalls disables parallel tool calls for the agent.
Directories ΒΆ
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
messages
Package messages provides types and functionality for handling multi-part message content in different formats including text, images, and audio.
|
Package messages provides types and functionality for handling multi-part message content in different formats including text, images, and audio. |
runstate
Package runstate provides functionality for managing the runtime state of message processing, including message aggregation, forking, and joining of message streams, as well as usage tracking.
|
Package runstate provides functionality for managing the runtime state of message processing, including message aggregation, forking, and joining of message streams, as well as usage tracking. |