search

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 9 Imported by: ? 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

Index

Constants

View Source
const (
	ProviderExa        = "exa"
	DefaultSearchCount = 5
	MaxSearchCount     = 10
	DefaultTimeoutSecs = 30
)

Variables

View Source
var DefaultFallbackOrder = []string{
	ProviderExa,
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider  string   `yaml:"provider"`
	Fallbacks []string `yaml:"fallbacks"`

	Exa ExaConfig `yaml:"exa"`
}

Config controls search provider selection and credentials.

func ApplyEnvDefaults

func ApplyEnvDefaults(cfg *Config) *Config

ApplyEnvDefaults fills empty config fields from environment variables.

func ConfigFromEnv

func ConfigFromEnv() *Config

ConfigFromEnv builds a search config using environment variables.

func (*Config) WithDefaults

func (c *Config) WithDefaults() *Config

type ExaConfig

type ExaConfig struct {
	Enabled           *bool  `yaml:"enabled"`
	BaseURL           string `yaml:"base_url"`
	APIKey            string `yaml:"api_key"`
	Type              string `yaml:"type"`
	Category          string `yaml:"category"`
	NumResults        int    `yaml:"num_results"`
	IncludeText       bool   `yaml:"include_text"`
	TextMaxCharacters int    `yaml:"text_max_chars"`
	Highlights        bool   `yaml:"highlights"`
}

type Request

type Request struct {
	Query      string
	Count      int
	Country    string
	SearchLang string
	UILang     string
	Freshness  string
}

Request represents a normalized web search request.

type Response

type Response struct {
	Query      string
	Provider   string
	Count      int
	TookMs     int64
	Results    []Result
	Answer     string
	Summary    string
	Definition string
	Warning    string
	NoResults  bool
	Cached     bool
	Extras     map[string]any
}

Response is a normalized search response.

func Search(ctx context.Context, req Request, cfg *Config) (*Response, error)

Search executes a search using the configured provider chain.

type Result

type Result struct {
	ID          string
	Title       string
	URL         string
	Description string
	Published   string
	SiteName    string
	Author      string
	Image       string
	Favicon     string
}

Result is a normalized search result.

Jump to

Keyboard shortcuts

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