agent

package
v0.0.0-...-3d45783 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 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 *AgentRunAggregator) bool

Example stop condition

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent represents a basic AI agent with its configuration and state

func NewAgent

func NewAgent(opts ...bootstrap.NewAgentConfigFunc) (*Agent, error)

NewAgent creates a new agent with the given provider

func (*Agent) AddTool

func (a *Agent) AddTool(tool *core.Tool) error

AddTool adds a tool to the agent's available tools

func (*Agent) CallTool

func (a *Agent) CallTool(ctx context.Context, tc *core.ToolCall) (*core.Message, error)

CallTool sends a message to the agent and gets a response

func (*Agent) GetMiddleware

func (a *Agent) GetMiddleware(name string) (core.Middleware, bool)

GetMiddleware returns a middleware by name

func (*Agent) GetTools

func (a *Agent) GetTools() []*core.Tool

GetTools returns the current set of available tools

func (*Agent) ListMiddleware

func (a *Agent) ListMiddleware() []*core.Middleware

ListMiddleware returns all registered middleware in priority order

func (*Agent) RegisterMiddleware

func (a *Agent) RegisterMiddleware(m *core.Middleware) error

RegisterMiddleware adds a middleware to the processing chain

func (*Agent) RemoveMiddleware

func (a *Agent) RemoveMiddleware(name string) error

RemoveMiddleware removes a middleware by name

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, opts ...RunOptionFunc) (*AgentRunAggregator, error)

Run implements the main agent loop

func (*Agent) RunStream

func (a *Agent) RunStream(ctx context.Context, opts ...RunOptionFunc) *StreamRunnerResults

RunStream supports a streaming channel from a provider

func (*Agent) SendMessageStream

func (a *Agent) SendMessageStream(ctx context.Context, m []*core.Message) (<-chan *core.Message, <-chan string, <-chan error)

SendMessage sends a message to the agent and gets a response

func (*Agent) SendMessages

func (a *Agent) SendMessages(ctx context.Context, m []*core.Message) (*core.Message, error)

SendMessage sends a message to the agent and gets a response

func (*Agent) Step

func (a *Agent) Step(ctx context.Context, message core.Message) (*core.Message, error)

Step executes a single step of the agent's logic based on a given role

type AgentRunAggregator

type AgentRunAggregator struct {
	Messages []*core.Message
}

AgentRunAggregator represents a single step in an agent's execution

func NewAgentRunAggregator

func NewAgentRunAggregator() *AgentRunAggregator

func (*AgentRunAggregator) Pop

func (ama *AgentRunAggregator) Pop() *core.Message

func (*AgentRunAggregator) Push

func (ama *AgentRunAggregator) Push(m ...*core.Message)

type AgentStopCondition

type AgentStopCondition func(step *AgentRunAggregator) bool

StopCondition is a function that determines if the agent should stop after its completed a step (i.e., a full "start" -> "doing work" -> "done" cycle)

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 AgentStopCondition) RunOptionFunc

WithStopCondition sets the stop condition option

type RunOptions

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

type StreamRunnerResults

type StreamRunnerResults struct {
	AggChan   <-chan AgentRunAggregator
	DeltaChan <-chan string
	ErrChan   <-chan error
}

type ToolMap

type ToolMap map[string]*core.Tool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL