Documentation
¶
Overview ¶
Package agent provides the AI agent runtime for omniagent.
Index ¶
- type Agent
- func (a *Agent) Close() error
- func (a *Agent) GetSkills() []*skills.Skill
- func (a *Agent) LoadSkills(dirs []string) error
- func (a *Agent) Process(ctx context.Context, sessionID, content string) (string, error)
- func (a *Agent) ProcessWithMemory(ctx context.Context, sessionID, content string) (string, error)
- func (a *Agent) RegisterTool(tool Tool)
- type BaseTool
- type Config
- type SearchArgs
- type SearchTool
- type Session
- func (sess *Session) AddMessage(role provider.Role, content string)
- func (sess *Session) Clear()
- func (sess *Session) GetMessages() []provider.Message
- func (sess *Session) GetMetadata(key string) (interface{}, bool)
- func (sess *Session) SetMetadata(key string, value interface{})
- func (sess *Session) Trim(n int)
- type SessionStore
- type Tool
- type ToolNotFoundError
- type ToolRegistry
- func (r *ToolRegistry) Execute(ctx context.Context, name string, args json.RawMessage) (string, error)
- func (r *ToolRegistry) Get(name string) (Tool, bool)
- func (r *ToolRegistry) GetTools() []provider.Tool
- func (r *ToolRegistry) List() []string
- func (r *ToolRegistry) Register(tool Tool)
- func (r *ToolRegistry) Unregister(name string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the AI agent that processes messages.
func (*Agent) LoadSkills ¶ added in v0.3.0
LoadSkills loads skills from the given directories.
func (*Agent) ProcessWithMemory ¶
ProcessWithMemory processes a message using conversation memory.
func (*Agent) RegisterTool ¶
RegisterTool registers a tool with the agent.
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool provides a base implementation for tools.
func NewBaseTool ¶
func NewBaseTool(name, description string, parameters map[string]interface{}, handler func(ctx context.Context, args json.RawMessage) (string, error)) *BaseTool
NewBaseTool creates a new base tool.
func (*BaseTool) Description ¶
func (*BaseTool) Parameters ¶
type Config ¶
type Config struct {
Provider string
Model string
APIKey string //nolint:gosec // G117: APIKey is intentionally stored for provider authentication
BaseURL string
Temperature float64
MaxTokens int
SystemPrompt string
Logger *slog.Logger
ObservabilityHook omnillm.ObservabilityHook
}
Config configures the agent.
type SearchArgs ¶
type SearchArgs struct {
Query string `json:"query"`
Type string `json:"type,omitempty"` // "web", "news", "images" (default: "web")
}
SearchArgs are the arguments for the search tool.
type SearchTool ¶
type SearchTool struct {
// contains filtered or unexported fields
}
SearchTool provides web search capabilities via omniserp.
func NewSearchTool ¶
func NewSearchTool() (*SearchTool, error)
NewSearchTool creates a new search tool.
func (*SearchTool) Description ¶
func (t *SearchTool) Description() string
func (*SearchTool) Execute ¶
func (t *SearchTool) Execute(ctx context.Context, argsJSON json.RawMessage) (string, error)
func (*SearchTool) Name ¶
func (t *SearchTool) Name() string
func (*SearchTool) Parameters ¶
func (t *SearchTool) Parameters() map[string]interface{}
type Session ¶
type Session struct {
ID string
Messages []provider.Message
CreatedAt time.Time
UpdatedAt time.Time
Metadata map[string]interface{}
// contains filtered or unexported fields
}
Session represents a conversation session.
func (*Session) AddMessage ¶
AddMessage adds a message to the session.
func (*Session) GetMessages ¶
GetMessages returns all messages in the session.
func (*Session) GetMetadata ¶
GetMetadata gets a metadata value.
func (*Session) SetMetadata ¶
SetMetadata sets a metadata value.
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore manages conversation sessions.
func NewSessionStore ¶
func NewSessionStore() *SessionStore
NewSessionStore creates a new session store.
func (*SessionStore) Get ¶
func (s *SessionStore) Get(id string) *Session
Get retrieves a session by ID, creating one if it doesn't exist.
type Tool ¶
type Tool interface {
// Name returns the tool name.
Name() string
// Description returns a description of what the tool does.
Description() string
// Parameters returns the JSON schema for the tool parameters.
Parameters() map[string]interface{}
// Execute runs the tool with the given arguments.
Execute(ctx context.Context, args json.RawMessage) (string, error)
}
Tool represents an agent tool that can be invoked.
type ToolNotFoundError ¶
type ToolNotFoundError struct {
Name string
}
ToolNotFoundError is returned when a tool is not found.
func (*ToolNotFoundError) Error ¶
func (e *ToolNotFoundError) Error() string
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry manages available tools.
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates a new tool registry.
func (*ToolRegistry) Execute ¶
func (r *ToolRegistry) Execute(ctx context.Context, name string, args json.RawMessage) (string, error)
Execute runs a tool by name with the given arguments.
func (*ToolRegistry) Get ¶
func (r *ToolRegistry) Get(name string) (Tool, bool)
Get retrieves a tool by name.
func (*ToolRegistry) GetTools ¶
func (r *ToolRegistry) GetTools() []provider.Tool
GetTools returns tool definitions for the LLM.
func (*ToolRegistry) List ¶
func (r *ToolRegistry) List() []string
List returns all registered tool names.
func (*ToolRegistry) Register ¶
func (r *ToolRegistry) Register(tool Tool)
Register adds a tool to the registry.
func (*ToolRegistry) Unregister ¶
func (r *ToolRegistry) Unregister(name string)
Unregister removes a tool from the registry.