search

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package search defines external web search and its Agent tool adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tool

func Tool(s Searcher, maxResults int) (tool.Tool, error)

Tool adapts s for Agent calls. maxResults bounds model-selected limits. Search results are untrusted content, never application instructions.

Types

type Request

type Request struct {
	Query string `json:"query"`
	Limit int    `json:"limit,omitempty"`
}

Request describes a web search. Limits are provider specific.

func (Request) Validate

func (r Request) Validate() error

Validate rejects empty queries and negative limits.

type Response

type Response struct {
	Results   []Result `json:"results"`
	RequestID string   `json:"request_id,omitempty"`
}

Response preserves source attribution and the provider request ID.

type Result

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

Result is an external source. Content is untrusted source material.

type Searcher

type Searcher interface {
	Search(context.Context, Request) (*Response, error)
}

Searcher searches external sources without fetching result URLs.

Jump to

Keyboard shortcuts

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