websearch

package
v7.68.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package websearch provides explicit Brave and DeepSeek web-search clients and tools.

Index

Constants

View Source
const ProviderBrave = "brave"
View Source
const ProviderDeepSeek = "deepseek"
View Source
const ToolName = "web_search"

Variables

This section is empty.

Functions

func NewTool

func NewTool(client *Client, options ToolOptions) tools.Tool

Types

type Client

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

Client has one immutable service binding and no automatic retry or fallback.

func NewBraveClient

func NewBraveClient(options ClientOptions) (*Client, error)

func NewDeepSeekClient

func NewDeepSeekClient(options ClientOptions) (*Client, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, request Request) (Result, error)

type ClientOptions

type ClientOptions struct {
	BaseURL string
	APIKey  string
	// ResolveAPIKey optionally resolves a live credential immediately before each call.
	ResolveAPIKey func(context.Context) (string, error)
	HTTPClient    *http.Client
	Timeout       time.Duration
}

ClientOptions binds a client to one host-selected service endpoint and credential. BaseURL is the Brave search endpoint or the DeepSeek connection base URL.

type HTTPError

type HTTPError = webapi.HTTPError

HTTPError reports a sanitized tool-service failure independently of model transport errors.

type Item

type Item struct {
	Title       string   `json:"title"`
	URL         string   `json:"url"`
	Snippet     string   `json:"snippet,omitempty"`
	Summary     string   `json:"summary,omitempty"`
	Content     string   `json:"content,omitempty"`
	SiteName    *string  `json:"site_name,omitempty"`
	SiteIcon    *string  `json:"site_icon,omitempty"`
	Date        *string  `json:"date,omitempty"`
	Authority   *int     `json:"authority,omitempty"`
	RerankScore *float64 `json:"rerank_score,omitempty"`
	Age         string   `json:"age,omitempty"`
}

Item preserves source fields without inventing absent metadata.

type Request

type Request struct {
	Query            string `json:"query"`
	Count            int    `json:"count,omitempty"`
	OriginalQuestion string `json:"ori_question,omitempty"`
	Localization     string `json:"localization,omitempty"`
	NeedContent      bool   `json:"need_content"`
	Country          string `json:"-"`
	SearchLang       string `json:"-"`
	Freshness        string `json:"-"`
}

Request describes a search. DeepSeek supports OriginalQuestion, Localization and NeedContent; Brave supports Country, SearchLang and Freshness. Unsupported fields are rejected.

type Result

type Result struct {
	Provider string `json:"provider"`
	Query    string `json:"query"`
	Results  []Item `json:"results"`
}

Result is a complete source response; an empty Results slice is a successful empty search.

type ToolOptions

type ToolOptions struct {
	Name          string
	Permission    tools.PermissionSpec
	PermissionFor tools.PermissionResolver
}

ToolOptions configures tool identity and host-owned authorization, never model-selected routing.

Jump to

Keyboard shortcuts

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