Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

feat: add Tavily as configurable search engine alongside SearXNG#1

Open
tavily-integrations wants to merge 2 commits intoJinFanZheng:mainfrom
tavily-integrations:feat/tavily-migration/web-search-tavily
Open

feat: add Tavily as configurable search engine alongside SearXNG#1
tavily-integrations wants to merge 2 commits intoJinFanZheng:mainfrom
tavily-integrations:feat/tavily-migration/web-search-tavily

Conversation

@tavily-integrations
Copy link
Copy Markdown

Summary

  • Added Tavily as an opt-in search backend selectable via --engine tavily, keeping SearXNG as the default
  • Created internal/search/tavily.go — HTTP client that POSTs to the Tavily /search REST API and maps results (title, url, content, score) into the existing SearchResult type
  • Added TavilyAPIKey field to SearchConfig struct, loaded from TAVILY_API_KEY env var or tavily_api_key JSON config key
  • Updated Search struct with engine-dispatch logic in Do() to route between SearXNG and Tavily
  • Updated CLI --engine flag to accept tavily in addition to searxng

Files changed

  • internal/config/config.go — Added TavilyAPIKey to SearchConfig
  • internal/config/loader.go — Read TAVILY_API_KEY env var; propagate field in mergeSearchConfig
  • internal/search/tavily.go — New file: Tavily REST API client
  • internal/search/search.go — Added engine dispatch, TavilyClient field, refactored Do() into doTavily/doSearXNG
  • cmd/web-search/main.go — Accept tavily as valid --engine value, pass engine to NewSearch

Dependency changes

  • None (Tavily API called via stdlib net/http)

Environment variable changes

  • Added TAVILY_API_KEY — required when using --engine tavily; SearXNG continues to work without it

Notes for reviewers

  • SearXNG remains the default engine; no existing behaviour changes
  • If --engine tavily is used without TAVILY_API_KEY set, a clear error is returned
  • No new Go module dependencies — uses stdlib net/http for the Tavily REST API

🤖 Generated with Claude Code

Automated Review

  • Passed after 2 attempt(s)
  • Final review: All four issues from the previous review have been correctly addressed. The Tavily integration is now functionally complete: config is loaded via config.Load() (picking up env vars and JSON files), API auth uses Authorization: Bearer header, CLI descriptions document Tavily, and topic/time_range parameters are properly mapped. The config layer changes (internal/config/config.go and internal/config/loader.go) are correctly included in the diff despite not being listed in the implementation summary. SearXNG behaviour is fully preserved. No new dependencies are introduced — Tavily is implemented using the standard library only, which is consistent with the existing SearXNG client pattern. One minor issue noted below about Tavily topic validation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant