websearch

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BraveProvider

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

BraveProvider implements the Provider interface for Brave Search API.

func NewBraveProvider

func NewBraveProvider(apiKey, apiURL string, pollTimeout, pollInterval int, httpClient *http.Client, logger Logger) *BraveProvider

NewBraveProvider creates a new BraveProvider instance.

func (*BraveProvider) Search

func (b *BraveProvider) Search(ctx context.Context, query string, limit int) (*SearchResponse, error)

Search performs a Brave Search and returns the results with optional pre-formatted answer.

type GoogleProvider

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

GoogleProvider implements the Provider interface for Google Custom Search API.

func NewGoogleProvider

func NewGoogleProvider(apiKey, searchEngineID, apiURL string, httpClient *http.Client, logger Logger) *GoogleProvider

NewGoogleProvider creates a new GoogleProvider instance.

func (*GoogleProvider) Search

func (g *GoogleProvider) Search(ctx context.Context, query string, limit int) (*SearchResponse, error)

Search performs a Google Custom Search and returns the results.

type Logger

type Logger interface {
	Debug(message string, keyValuePairs ...any)
	Info(message string, keyValuePairs ...any)
	Warn(message string, keyValuePairs ...any)
	Error(message string, keyValuePairs ...any)
}

Logger abstracts the logging interface used by providers.

type Provider

type Provider interface {
	Search(ctx context.Context, query string, limit int) (*SearchResponse, error)
}

Provider defines the interface for web search providers.

type SearchResponse

type SearchResponse struct {
	Answer  string         // Optional pre-formatted answer with citations (e.g., Brave)
	Results []SearchResult // List of search results
}

SearchResponse represents the response from a search provider.

type SearchResult

type SearchResult struct {
	Title   string
	URL     string
	Snippet string
}

SearchResult represents a single search result.

Jump to

Keyboard shortcuts

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