websearch

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package websearch provides a web search client with multiple provider backends.

The package exposes a Client interface that can be implemented by different backends (direct API calls, proxy through Airlock, etc.). NewClient creates a direct client that calls provider APIs with explicit credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTool

func NewTool(client Client) tool.Tool

NewTool wraps a Client as a tool.Tool for use in Sol's agent loop or goai. The client can be any implementation — direct API, proxy through Airlock, etc.

Types

type Client

type Client interface {
	Search(ctx context.Context, req Request) (*Response, error)
}

Client searches the web.

type DirectClient

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

DirectClient calls search provider APIs directly.

func NewClient

func NewClient(opts Options) *DirectClient

NewClient creates a direct search client from explicit options.

func (*DirectClient) Search

func (c *DirectClient) Search(ctx context.Context, req Request) (*Response, error)

Search implements Client.

type Options

type Options struct {
	Provider string // "brave", "perplexity", "grok", "gemini", "kimi" (required)
	APIKey   string // provider's API key (required)
	Model    string // for LLM-based providers; defaults per provider
}

Options configures a direct search client. Mirrors the LLM provider pattern: single provider, single key, caller reads env.

type Request

type Request struct {
	Query     string // search query (required)
	Count     int    // number of results, 1-10; 0 = provider default (5)
	Freshness string // time filter: "day", "week", "month", "year"
	Country   string // 2-letter country code
	Language  string // ISO 639-1 language code
}

Request describes a web search query.

type Response

type Response struct {
	Results   []Result // raw results (Brave/Perplexity) or citation sources (LLM providers)
	Synthesis string   // synthesized answer; only set by LLM-based providers (Grok, Gemini, Kimi)
	Provider  string   // which provider produced these results
}

Response contains web search results.

type Result

type Result struct {
	Title   string
	URL     string
	Snippet string
}

Result is a single search result.

type ToolInput

type ToolInput struct {
	Query     string `json:"query" description:"Search query string"`
	Count     int    `json:"count,omitempty" description:"Number of results to return (1-10, default 5)"`
	Freshness string `json:"freshness,omitempty" description:"Time filter: day, week, month, or year" enum:"day,week,month,year"`
	Country   string `json:"country,omitempty" description:"2-letter country code for region-specific results (e.g. US, DE)"`
	Language  string `json:"language,omitempty" description:"ISO 639-1 language code for results (e.g. en, de, fr)"`
}

ToolInput is the JSON schema for the web_search tool.

Jump to

Keyboard shortcuts

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