Skip to content

feat: add Tavily as configurable search backend alongside TinyFish - #2

Open
tavily-integrations wants to merge 2 commits into
mrvarmazyar:mainfrom
Tavily-FDE:feat/tavily-migration/web-research-tinyfish-to-tavily
Open

feat: add Tavily as configurable search backend alongside TinyFish#2
tavily-integrations wants to merge 2 commits into
mrvarmazyar:mainfrom
Tavily-FDE:feat/tavily-migration/web-research-tinyfish-to-tavily

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily as an opt-in, configurable search backend alongside the existing TinyFish provider. When TAVILY_API_KEY is set (or SEARCH_PROVIDER=tavily), the service uses Tavily; otherwise it falls back to TinyFish. No existing code is removed.

Changes

  • internal/search/tinyfish.go — Renamed Search() to SearchTinyFish() so the dispatcher can call providers by name.
  • internal/search/tavily.go (new) — Implements SearchTavily() using Tavily's REST API (POST https://api.tavily.com/search), mapping response fields to the existing Result struct.
  • internal/search/provider.go (new) — Top-level Search() dispatcher that reads SEARCH_PROVIDER env var (tavily|tinyfish) and auto-detects based on TAVILY_API_KEY presence when unset.
  • cmd/wr/main.go — Added TAVILY_API_KEY and SEARCH_PROVIDER to cmdSetup() checks and usage() text.

Dependency Changes

  • None — Tavily REST API is called with net/http (same pattern as TinyFish).

Environment Variable Changes

  • TAVILY_API_KEY — Tavily API key (https://app.tavily.com)
  • SEARCH_PROVIDER — Optional selector: tavily or tinyfish (auto-detected if omitted)

Notes for Reviewers

  • internal/research/service.go calls search.Search() which now routes through the new dispatcher — no changes needed there.
  • The MCP server (cmd/wr-mcp/main.go) inherits the new capability transitively.
  • Go toolchain was not available in the build environment for compilation verification, but all references and types are consistent.

Automated Review

  • Passed after 2 attempt(s)
  • Final review: The migration correctly implements Tavily as an additive search provider alongside TinyFish. All four issues from the previous review cycle have been resolved: (1) cmdSetup() now requires at least one of TINYFISH_API_KEY or TAVILY_API_KEY, (2) the usage string is updated to "provider auto-detected", (3) http.StatusOK replaces the magic 200, and (4) the unused Score field is removed. The new provider.go dispatcher cleanly routes through the existing search.Search call surface, so both cmd/wr and cmd/wr-mcp (which go through research.Service) work without changes. No new external dependencies are needed since the Tavily client uses only stdlib. No regressions detected.

@mrvarmazyar

Copy link
Copy Markdown
Owner

@tavily-integrations thanks for contribution, please rebase the branch with main :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants