search

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package search is the agent on the open web: finding pages (Searcher) and reading them (Fetcher).

A search returns only pages the provider actually cites (never a URL a model made up), and the fetcher reads only https pages on public addresses, with size and time limits. What it reads is untrusted material, never instructions; the abilities fence it.

Index

Constants

This section is empty.

Variables

View Source
var ErrNothing = errors.New("nothing to read")

Functions

This section is empty.

Types

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, url string) (Page, error)
}

type Found

type Found struct {
	Results []Result
	CostUSD float64 // what the provider charges in tokens; a per-search fee, if any, is billed on top
}

type HTTPFetcher

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

func NewFetcher

func NewFetcher() *HTTPFetcher

NewFetcher returns a fetcher that only connects to public addresses: no localhost, private networks or link-local (cloud metadata) addresses, even through a redirect or a name that resolves to one.

func (*HTTPFetcher) Fetch

func (f *HTTPFetcher) Fetch(ctx context.Context, raw string) (Page, error)

Fetch reads a page: https only, HTML or plain text, its readable text.

type OpenAI

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

func NewOpenAI

func NewOpenAI(apiKey, model, baseURL string, price pricing.Price) *OpenAI

func (*OpenAI) Search

func (o *OpenAI) Search(ctx context.Context, query string, n int) (Found, error)

Search asks the model to search the web and list the best pages. Only pages its search actually retrieved (the search's sources, or the answer's citations) are kept, so no URL is made up.

type Page

type Page struct {
	URL   string
	Title string
	Text  string
}

type Result

type Result struct {
	Title   string
	URL     string
	Snippet string
}

type Searcher

type Searcher interface {
	Search(ctx context.Context, query string, n int) (Found, error)
}

Jump to

Keyboard shortcuts

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