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: 0

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