agent

package
v0.0.0-...-246be7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

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) CallTool

func (a *DefaultAgent) CallTool(ctx context.Context, tc *types.ToolCall) (*types.Message, error)

CallTool sends a message to the agent and gets a response

func (*DefaultAgent) Run

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 WithInput

func WithInput(input string) RunOptionFunc

WithInput sets the input string option

func WithStopCondition

func WithStopCondition(stopCondition types.AgentStopCondition) RunOptionFunc

WithStopCondition sets the stop condition option

type RunOptions

type RunOptions struct {
	Input         string
	StopCondition types.AgentStopCondition
	Images        []*types.Image
	RunErrs       []error
}

type ToolMap

type ToolMap map[string]types.Tool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳