Documentation
¶
Overview ¶
Package tools provides built-in tool implementations for the agent loop.
Index ¶
- Variables
- type BashTool
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) Execute(call api.ToolCall) (string, error)
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) Has(name string) bool
- func (r *Registry) Names() []string
- func (r *Registry) Register(tool Tool)
- func (r *Registry) RegisterBash()
- func (r *Registry) RegisterWebFetch()
- func (r *Registry) RegisterWebSearch()
- func (r *Registry) Tools() api.Tools
- func (r *Registry) Unregister(name string)
- type Tool
- type WebFetchTool
- type WebSearchTool
Constants ¶
This section is empty.
Variables ¶
var ErrWebFetchAuthRequired = errors.New("web fetch requires authentication")
ErrWebFetchAuthRequired is returned when web fetch requires authentication
var ErrWebSearchAuthRequired = errors.New("web search requires authentication")
ErrWebSearchAuthRequired is returned when web search requires authentication
Functions ¶
This section is empty.
Types ¶
type BashTool ¶
type BashTool struct{}
BashTool implements shell command execution.
func (*BashTool) Description ¶
Description returns a description of the tool.
func (*BashTool) Schema ¶
func (b *BashTool) Schema() api.ToolFunction
Schema returns the tool's parameter schema.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages available tools.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry creates a registry with all built-in tools. Tools can be disabled via environment variables: - OLLAMA_AGENT_DISABLE_WEBSEARCH=1 disables web_search - OLLAMA_AGENT_DISABLE_BASH=1 disables bash
func (*Registry) RegisterBash ¶
func (r *Registry) RegisterBash()
RegisterBash adds the bash tool to the registry.
func (*Registry) RegisterWebFetch ¶
func (r *Registry) RegisterWebFetch()
RegisterWebFetch adds the web fetch tool to the registry.
func (*Registry) RegisterWebSearch ¶
func (r *Registry) RegisterWebSearch()
RegisterWebSearch adds the web search tool to the registry.
func (*Registry) Unregister ¶
Unregister removes a tool from the registry by name.
type Tool ¶
type Tool interface {
// Name returns the tool's unique identifier.
Name() string
// Description returns a human-readable description of what the tool does.
Description() string
// Schema returns the tool's parameter schema for the LLM.
Schema() api.ToolFunction
// Execute runs the tool with the given arguments.
Execute(args map[string]any) (string, error)
}
Tool defines the interface for agent tools.
type WebFetchTool ¶
type WebFetchTool struct{}
WebFetchTool implements web page fetching using Ollama's hosted API.
func (*WebFetchTool) Description ¶
func (w *WebFetchTool) Description() string
Description returns a description of the tool.
func (*WebFetchTool) Execute ¶
func (w *WebFetchTool) Execute(args map[string]any) (string, error)
Execute fetches content from a web page. Uses Ollama key signing for authentication - this makes requests via ollama.com API.
func (*WebFetchTool) Schema ¶
func (w *WebFetchTool) Schema() api.ToolFunction
Schema returns the tool's parameter schema.
type WebSearchTool ¶
type WebSearchTool struct{}
WebSearchTool implements web search using Ollama's hosted API.
func (*WebSearchTool) Description ¶
func (w *WebSearchTool) Description() string
Description returns a description of the tool.
func (*WebSearchTool) Execute ¶
func (w *WebSearchTool) Execute(args map[string]any) (string, error)
Execute performs the web search. Uses Ollama key signing for authentication - this makes requests via ollama.com API.
func (*WebSearchTool) Schema ¶
func (w *WebSearchTool) Schema() api.ToolFunction
Schema returns the tool's parameter schema.