webtool

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWebFetch added in v1.12.0

func NewWebFetch(cfg *WebFetchConfig) (tool.CallableTool, error)

NewWebFetch creates a new web_fetch tool using FunctionTool.

func NewWebRequest

func NewWebRequest(cfg *WebRequestConfig) (tool.CallableTool, error)

NewWebRequest creates a new web_request tool using FunctionTool.

func NewWebSearch added in v1.12.0

func NewWebSearch(cfg *WebSearchConfig) (tool.CallableTool, error)

NewWebSearch creates a new web_search tool.

Types

type SearchProvider added in v1.12.0

type SearchProvider interface {
	Search(ctx tool.Context, args WebSearchArgs) (*SearchResponse, error)
}

SearchProvider defines the interface for search backends.

type SearchResponse added in v1.12.0

type SearchResponse struct {
	Results []SearchResult `json:"results"`
	Answer  string         `json:"answer,omitempty"` // Direct answer if supported by provider
}

SearchResponse encapsulates the results and metadata.

type SearchResult added in v1.12.0

type SearchResult struct {
	Title   string  `json:"title"`
	URL     string  `json:"url"`
	Content string  `json:"content"`
	Score   float64 `json:"score,omitempty"`
}

SearchResult represents a single search result.

type TavilyProvider added in v1.12.0

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

func NewTavilyProvider added in v1.12.0

func NewTavilyProvider(apiKey string, timeout time.Duration) *TavilyProvider

func (*TavilyProvider) Search added in v1.12.0

func (p *TavilyProvider) Search(ctx tool.Context, args WebSearchArgs) (*SearchResponse, error)

type WebFetchArgs added in v1.12.0

type WebFetchArgs struct {
	URL string `json:"url" jsonschema:"required,description=The URL to fetch content from"`
}

WebFetchArgs defines the parameters for the standard web_fetch tool. Schema follows Anthropic's Server Tool definition.

type WebFetchConfig added in v1.12.0

type WebFetchConfig struct {
	Timeout         time.Duration
	MaxRetries      int
	MaxResponseSize int64
	AllowedDomains  []string
	DeniedDomains   []string
	AllowRedirects  bool
	UserAgent       string
}

WebFetchConfig defines configuration for the web_fetch tool.

type WebRequestArgs

type WebRequestArgs struct {
	URL     string            `json:"url" jsonschema:"required,description=The URL to request"`
	Method  string            `` /* 146-byte string literal not displayed */
	Headers map[string]string `json:"headers,omitempty" jsonschema:"description=HTTP headers as key-value pairs"`
	Body    string            `json:"body,omitempty" jsonschema:"description=Request body (for POST PUT PATCH)"`
}

WebRequestArgs defines the parameters for making HTTP requests.

type WebRequestConfig

type WebRequestConfig struct {
	Timeout         time.Duration
	MaxRetries      int
	MaxRequestSize  int64
	MaxResponseSize int64
	AllowedDomains  []string
	DeniedDomains   []string
	AllowedMethods  []string
	AllowRedirects  bool
	MaxRedirects    int
	UserAgent       string
}

WebRequestConfig defines configuration for the web_request tool.

type WebSearchArgs added in v1.12.0

type WebSearchArgs struct {
	Query string `json:"query" jsonschema:"required,description=The search query"`
	Topic string `` /* 128-byte string literal not displayed */
	// TimeRange filters results by date. Supported values: day, week, month, year.
	TimeRange string `` /* 148-byte string literal not displayed */
	// MaxResults limits the number of results returned (default: 5).
	MaxResults int `json:"max_results,omitempty" jsonschema:"description=Maximum number of results to return"`
	// IncludeDomains list of domains to specifically include.
	IncludeDomains []string `json:"include_domains,omitempty" jsonschema:"description=Domains to include in search"`
	// ExcludeDomains list of domains to specifically exclude.
	ExcludeDomains []string `json:"exclude_domains,omitempty" jsonschema:"description=Domains to exclude from search"`
}

WebSearchArgs defines the parameters for the standard web_search tool. Designed to be generic across providers while supporting common advanced features.

type WebSearchConfig added in v1.12.0

type WebSearchConfig struct {
	Provider string // tavily, serpapi, google (default: tavily)
	APIKey   string // If empty, loaded from env based on provider
	Timeout  time.Duration
}

WebSearchConfig configures the tool.

Jump to

Keyboard shortcuts

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