Deep-Research-AI-Agent icon indicating copy to clipboard operation
Deep-Research-AI-Agent copied to clipboard

feat: add Tavily as configurable search provider alongside Exa

Open tavily-integrations opened this issue 6 months ago • 0 comments

Summary

Adds Tavily as an additive, configurable search backend alongside the existing Exa integration. A SEARCH_PROVIDER env var ('exa' | 'tavily', default 'exa') controls which provider the search() function dispatches to. Exa remains fully intact as the default.

Changes

src/app/api/deep-research/services.ts

  • Added @tavily/core import
  • Added lazy Tavily client initialization (getTavily()) mirroring the existing getExa() pattern
  • Exported tavilySearch() wrapper that calls tavily.search() with searchDepth: "advanced" and maps results to the existing SearchResult shape ({title, url, content})

src/app/api/deep-research/research-functions.ts

  • Imported tavilySearch from services
  • Updated search() to read SEARCH_PROVIDER env var and branch: uses tavilySearch() when 'tavily', otherwise uses existing Exa searchAndContents() path

.env.example

  • Added TAVILY_API_KEY and SEARCH_PROVIDER=exa entries

package.json

  • Added @tavily/core (^0.7.3) dependency

Dependency changes

  • Added @tavily/core ^0.7.3 to dependencies

Environment variable changes

  • TAVILY_API_KEY — required when SEARCH_PROVIDER=tavily
  • SEARCH_PROVIDER — optional, defaults to 'exa'; set to 'tavily' to use Tavily

Notes for reviewers

  • Exa dependency (exa-js) and EXA_SEARCH_API_KEY are fully preserved
  • The SearchResult type is already provider-agnostic, no type changes needed
  • Pre-existing TS error in page.tsx (unrelated image import) is unchanged

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is correct and complete. The @tavily/core dependency is added to package.json, lazy client initialization and tavilySearch() wrapper are implemented consistently with the existing Exa pattern in services.ts, the search() function in research-functions.ts correctly branches on SEARCH_PROVIDER env var defaulting to "exa", and .env.example documents both new variables. Exa functionality is fully preserved. The only notable issue is an unintended package-lock.json being committed to a project that uses bun (a bun.lock already exists), which is a minor inconsistency and should be removed.

tavily-integrations avatar May 06 '26 18:05 tavily-integrations