Skip to content

feat: add Tavily as configurable search provider alongside RapidAPI - #1

Open
manisrinivasan2k1 wants to merge 1 commit into
edsmkt:mainfrom
Tavily-FDE:feat/tavily-migration/ferret-worker-search
Open

feat: add Tavily as configurable search provider alongside RapidAPI#1
manisrinivasan2k1 wants to merge 1 commit into
edsmkt:mainfrom
Tavily-FDE:feat/tavily-migration/ferret-worker-search

Conversation

@manisrinivasan2k1

Copy link
Copy Markdown

Summary

Adds Tavily Search API as a runtime-selectable search provider alongside the existing RapidAPI Google Search, controlled by the SEARCH_PROVIDER environment variable.

What changed

  • worker.js: Added tavilySearch() helper that POSTs to https://api.tavily.com/search, formats results as numbered title/url/snippet list, and logs with via: 'tavily'. Renamed existing webSearch() to rapidapiSearch() and introduced a new webSearch() dispatcher that routes based on env.SEARCH_PROVIDER.
  • wrangler.toml: Added SEARCH_PROVIDER = "rapidapi" default var and a comment for the TAVILY_API_KEY secret.
  • AGENT.md: Added Tavily drop-in example to the "How to Swap the Search Provider" section and added TAVILY_API_KEY and SEARCH_PROVIDER to the Environment Variables Reference table.

Files changed

  • worker.js
  • wrangler.toml
  • AGENT.md

Dependency changes

  • None — Tavily REST API is called via native fetch, consistent with the rest of worker.js.

Environment variable changes

  • SEARCH_PROVIDER (var, default: "rapidapi") — set to "tavily" to activate Tavily
  • TAVILY_API_KEY (secret, optional) — required only when SEARCH_PROVIDER=tavily

Notes for reviewers

  • This is an additive change — all existing RapidAPI code paths are preserved and remain the default.
  • No npm packages added; Tavily is called via native fetch like all other external APIs in the worker.
  • The dispatcher pattern (webSearch() routing to provider-specific functions) makes future provider additions straightforward.

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The migration correctly adds Tavily as a configurable search provider alongside the existing RapidAPI Google Search. The implementation uses the proper Tavily REST API endpoint and request structure, the dispatcher pattern is clean, the default behavior is preserved (rapidapi), and all three files are appropriately updated. No regressions introduced.

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.

1 participant