Documentation
¶
Index ¶
- func DefaultStopCondition(agg *types.AgentRunAggregator) bool
- type DefaultAgent
- func (a *DefaultAgent) AddTool(tool types.Tool) error
- func (a *DefaultAgent) CallTool(ctx context.Context, tc *types.ToolCall) (*types.Message, error)
- func (a *DefaultAgent) Run(ctx context.Context, opts ...RunOptionFunc) *types.AgentRunAggregator
- func (a *DefaultAgent) RunStream(ctx context.Context, input string, stopCondition types.AgentStopCondition) (<-chan types.AgentRunAggregator, <-chan string, <-chan error)
- func (a *DefaultAgent) SendMessageStream(ctx context.Context, m *types.Message) (<-chan *types.Message, <-chan string, <-chan error)
- func (a *DefaultAgent) SendMessages(ctx context.Context, agg *types.AgentRunAggregator, m ...*types.Message) (*types.Message, error)
- type NewAgentConfig
- type RunOptionFunc
- type RunOptions
- type ToolMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStopCondition ¶
func DefaultStopCondition(agg *types.AgentRunAggregator) bool
Example stop condition
Types ¶
type DefaultAgent ¶
type DefaultAgent struct {
// contains filtered or unexported fields
}
DefaultAgent represents a basic AI agent with its configuration and state
func NewAgent ¶
func NewAgent(config *NewAgentConfig) *DefaultAgent
NewAgent creates a new agent with the given provider
func (*DefaultAgent) AddTool ¶
func (a *DefaultAgent) AddTool(tool types.Tool) error
AddTool adds a tool to the agent's available tools
func (*DefaultAgent) Run ¶
func (a *DefaultAgent) Run(ctx context.Context, opts ...RunOptionFunc) *types.AgentRunAggregator
Run implements the main agent loop
func (*DefaultAgent) RunStream ¶
func (a *DefaultAgent) RunStream(ctx context.Context, input string, stopCondition types.AgentStopCondition) (<-chan types.AgentRunAggregator, <-chan string, <-chan error)
RunStream supports a streaming channel from a provider
func (*DefaultAgent) SendMessageStream ¶
func (a *DefaultAgent) SendMessageStream(ctx context.Context, m *types.Message) (<-chan *types.Message, <-chan string, <-chan error)
SendMessage sends a message to the agent and gets a response
func (*DefaultAgent) SendMessages ¶
func (a *DefaultAgent) SendMessages(ctx context.Context, agg *types.AgentRunAggregator, m ...*types.Message) (*types.Message, error)
SendMessage sends a message to the agent and gets a response
type NewAgentConfig ¶
type NewAgentConfig struct { // The core.Provider this agent will use Provider core.Provider // Maximum number of steps before forcing stop MaxSteps int // Initial set of tools Tools []types.Tool // Initial system prompt SystemPrompt string Logger *slog.Logger Memory core.MemoryStorer }
NewAgentConfig holds configuration for agent initialization
type RunOptionFunc ¶
type RunOptionFunc func(*RunOptions)
RunOptionFunc is a function type that modifies RunOptions
func WithImageBase64 ¶
func WithImageBase64(encoding string, mimeType string) RunOptionFunc
func WithImagePath ¶
func WithImagePath(path string) RunOptionFunc
func WithStopCondition ¶
func WithStopCondition(stopCondition types.AgentStopCondition) RunOptionFunc
WithStopCondition sets the stop condition option
type RunOptions ¶
Click to show internal directories.
Click to hide internal directories.