Skip to content

feat: add Tavily as configurable search provider alongside Exa#8

Open
tavily-integrations wants to merge 1 commit into
codebucks27:mainfrom
Tavily-FDE:feat/tavily-migration/deep-research-exa-to-tavily
Open

feat: add Tavily as configurable search provider alongside Exa#8
tavily-integrations wants to merge 1 commit into
codebucks27:mainfrom
Tavily-FDE:feat/tavily-migration/deep-research-exa-to-tavily

Conversation

@tavily-integrations
Copy link
Copy Markdown

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.

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