providers

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProviderAvailable

func IsProviderAvailable() bool

IsProviderAvailable checks if any provider is configured.

func IsValidMode

func IsValidMode(mode string) bool

IsValidMode checks if the given mode is valid.

func ProviderDebugInfo

func ProviderDebugInfo() map[string]bool

ProviderDebugInfo returns debug information about provider configuration.

Types

type ExaProvider

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

ExaProvider implements search using Exa API.

func NewExaProvider

func NewExaProvider() *ExaProvider

NewExaProvider creates a new Exa search provider.

func NewExaProviderWithAPIKey

func NewExaProviderWithAPIKey(apiKey string) *ExaProvider

func (*ExaProvider) IsConfigured

func (p *ExaProvider) IsConfigured() bool

IsConfigured checks if the provider is configured with API key.

func (*ExaProvider) Name

func (p *ExaProvider) Name() string

Name returns the provider name.

func (*ExaProvider) Search

func (p *ExaProvider) Search(input SearchInput) (ProviderOutput, error)

Search performs a web search using Exa.

type ExaResponse

type ExaResponse struct {
	Results []struct {
		Title     string  `json:"title"`
		URL       string  `json:"url"`
		Snippet   string  `json:"snippet"`
		Published string  `json:"published"`
		Score     float64 `json:"score"`
	} `json:"results"`
}

ExaResponse represents the Exa API response.

type JinaProvider

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

JinaProvider implements search using Jina API.

func NewJinaProvider

func NewJinaProvider() *JinaProvider

NewJinaProvider creates a new Jina search provider.

func NewJinaProviderWithAPIKey

func NewJinaProviderWithAPIKey(apiKey string) *JinaProvider

func (*JinaProvider) IsConfigured

func (p *JinaProvider) IsConfigured() bool

IsConfigured checks if the provider is configured with API key.

func (*JinaProvider) Name

func (p *JinaProvider) Name() string

Name returns the provider name.

func (*JinaProvider) Search

func (p *JinaProvider) Search(input SearchInput) (ProviderOutput, error)

Search performs a web search using Jina.

type JinaResponse

type JinaResponse struct {
	Code    int `json:"code"`
	Message struct {
		Results []struct {
			Title       string `json:"title"`
			URL         string `json:"url"`
			Description string `json:"description"`
			Icon        string `json:"icon"`
		} `json:"data"`
	} `json:"message"`
}

JinaResponse represents the Jina API response.

type LangSearchProvider

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

LangSearchProvider implements search using the LangSearch API. Free tier requires an API key — register at langsearch.com (no credit card).

func NewLangSearchProvider

func NewLangSearchProvider() *LangSearchProvider

func NewLangSearchProviderWithAPIKey

func NewLangSearchProviderWithAPIKey(apiKey string) *LangSearchProvider

func (*LangSearchProvider) IsConfigured

func (p *LangSearchProvider) IsConfigured() bool

func (*LangSearchProvider) Name

func (p *LangSearchProvider) Name() string

func (*LangSearchProvider) Search

func (p *LangSearchProvider) Search(input SearchInput) (ProviderOutput, error)

type ProviderMode

type ProviderMode string

ProviderMode defines the search provider selection mode.

const (
	ProviderModeAuto       ProviderMode = "auto"
	ProviderModeCustom     ProviderMode = "custom"
	ProviderModeTavily     ProviderMode = "tavily"
	ProviderModeSearXNG    ProviderMode = "searxng"
	ProviderModeJina       ProviderMode = "jina"
	ProviderModeExa        ProviderMode = "exa"
	ProviderModeLangSearch ProviderMode = "langsearch"
	ProviderModeFirecrawl  ProviderMode = "firecrawl"
	ProviderModeBing       ProviderMode = "bing"
	ProviderModeYou        ProviderMode = "you"
	ProviderModeLinkup     ProviderMode = "linkup"
	ProviderModeMojeek     ProviderMode = "mojeek"
)

func GetCurrentMode

func GetCurrentMode() ProviderMode

GetProviderMode returns the current provider mode.

func ProviderModeFromEnv

func ProviderModeFromEnv() ProviderMode

ProviderModeFromEnv returns the configured provider mode from environment.

type ProviderOutput

type ProviderOutput struct {
	Hits            []SearchHit
	ProviderName    string
	DurationSeconds float64
}

ProviderOutput represents the result of a provider search.

func RunSearch

func RunSearch(input SearchInput, chain []SearchProvider, mode ProviderMode) (ProviderOutput, error)

RunSearch executes a search using the provider chain. In auto mode, it tries each provider in order and falls through on failure. In specific mode, it fails immediately if the provider is not configured.

func Search(input SearchInput) (ProviderOutput, error)

Search performs a search using the configured provider mode.

type SearXNGProvider

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

SearXNGProvider wraps the full-featured searxng.Client and satisfies SearchProvider. It ports all key behaviours from the mcp-searxng TypeScript server:

  • HTML fallback when the instance does not serve JSON (always enabled)
  • Basic auth (SEARXNG_AUTH_USERNAME / AUTH_USERNAME)
  • Full search params (language, time_range, safesearch, categories, engines)
  • Custom User-Agent and proxy support
  • Configurable timeout (SEARXNG_TIMEOUT_MS)

func NewSearXNGProvider

func NewSearXNGProvider() *SearXNGProvider

NewSearXNGProvider creates a provider configured from environment variables. Reads SEARXNG_URL or SEARXNG_BASE_URL for the instance base URL.

func NewSearXNGProviderWithBaseURL

func NewSearXNGProviderWithBaseURL(baseURL string) *SearXNGProvider

NewSearXNGProviderWithBaseURL creates a provider targeting a specific URL.

func NewSearXNGProviderWithConfig

func NewSearXNGProviderWithConfig(baseURL, username, password string) *SearXNGProvider

NewSearXNGProviderWithConfig creates a provider with explicit URL and optional Basic Auth credentials. username and password are empty when the SearXNG instance has no HTTP Basic Auth.

func (*SearXNGProvider) IsConfigured

func (p *SearXNGProvider) IsConfigured() bool

func (*SearXNGProvider) Name

func (p *SearXNGProvider) Name() string

func (*SearXNGProvider) Search

func (p *SearXNGProvider) Search(input SearchInput) (ProviderOutput, error)

type SearchHit

type SearchHit struct {
	Title       string
	URL         string
	Description string
	Source      string
}

SearchHit represents a single search result.

type SearchInput

type SearchInput struct {
	Ctx            context.Context // propagated to HTTP requests; nil falls back to context.Background()
	Query          string
	AllowedDomains []string
	BlockedDomains []string
}

SearchInput represents the input for a search operation.

type SearchProvider

type SearchProvider interface {
	Name() string
	IsConfigured() bool
	Search(input SearchInput) (ProviderOutput, error)
}

SearchProvider defines the interface for search backends.

func AllProviders

func AllProviders() []SearchProvider

AllProviders returns all available search providers in registration order. Note: custom provider is intentionally excluded from the auto chain.

func GetConfiguredProviders

func GetConfiguredProviders() []SearchProvider

GetConfiguredProviders returns only the providers that are configured.

func GetProviderChain

func GetProviderChain(mode ProviderMode, allProviders []SearchProvider) []SearchProvider

GetProviderChain returns the list of providers to try based on the mode.

type TavilyProvider

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

TavilyProvider implements search using Tavily API.

func NewTavilyProvider

func NewTavilyProvider() *TavilyProvider

NewTavilyProvider creates a new Tavily search provider.

func NewTavilyProviderWithAPIKey

func NewTavilyProviderWithAPIKey(apiKey string) *TavilyProvider

func (*TavilyProvider) IsConfigured

func (p *TavilyProvider) IsConfigured() bool

IsConfigured checks if the provider is configured with API key.

func (*TavilyProvider) Name

func (p *TavilyProvider) Name() string

Name returns the provider name.

func (*TavilyProvider) Search

func (p *TavilyProvider) Search(input SearchInput) (ProviderOutput, error)

Search performs a web search using Tavily.

type TavilyResponse

type TavilyResponse struct {
	Results []struct {
		Title       string `json:"title"`
		URL         string `json:"url"`
		Content     string `json:"content"`
		PublishedOn string `json:"published_on"`
	} `json:"results"`
}

TavilyResponse represents the Tavily API response.

Jump to

Keyboard shortcuts

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