websearch

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package websearch provides a pluggable web search interface with multiple provider backends (DuckDuckGo, Tavily, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuckDuckGo

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

DuckDuckGo implements web search using DuckDuckGo's lite HTML interface. This is a free, no-API-key-required provider. It scrapes the lightweight HTML search page (lite.duckduckgo.com) for results.

func NewDuckDuckGo

func NewDuckDuckGo() *DuckDuckGo

NewDuckDuckGo creates a DuckDuckGo search provider.

func (*DuckDuckGo) Name

func (d *DuckDuckGo) Name() string

Name returns the provider identifier.

func (*DuckDuckGo) Search

func (d *DuckDuckGo) Search(ctx context.Context, query string, maxResults int) ([]Result, error)

Search performs a DuckDuckGo search using the lite HTML endpoint. It also tries the instant answer API for quick results.

type Provider

type Provider interface {
	Search(ctx context.Context, query string, maxResults int) ([]Result, error)
	Name() string
}

Provider performs web searches and returns structured results.

func NewProvider

func NewProvider(cfg config.WebSearchConfig) (Provider, error)

NewProvider creates a search provider based on config.

type Result

type Result struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet"`
}

Result represents a single search result.

type Tavily

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

Tavily implements web search using the Tavily Search API. Tavily is purpose-built for AI agents with prompt injection protection and structured results optimized for LLM reasoning.

func NewTavily

func NewTavily(apiKey string) *Tavily

NewTavily creates a Tavily search provider.

func (*Tavily) Name

func (t *Tavily) Name() string

Name returns the provider identifier.

func (*Tavily) Search

func (t *Tavily) Search(ctx context.Context, query string, maxResults int) ([]Result, error)

Search performs a Tavily search.

Jump to

Keyboard shortcuts

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