Deep-Research-AI-Agent
Deep-Research-AI-Agent copied to clipboard
feat: add Tavily as configurable search provider alongside Exa
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/coreimport - Added lazy Tavily client initialization (
getTavily()) mirroring the existinggetExa()pattern - Exported
tavilySearch()wrapper that callstavily.search()withsearchDepth: "advanced"and maps results to the existingSearchResultshape ({title, url, content})
src/app/api/deep-research/research-functions.ts
- Imported
tavilySearchfrom services - Updated
search()to readSEARCH_PROVIDERenv var and branch: usestavilySearch()when'tavily', otherwise uses existing ExasearchAndContents()path
.env.example
- Added
TAVILY_API_KEYandSEARCH_PROVIDER=exaentries
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 whenSEARCH_PROVIDER=tavilySEARCH_PROVIDER— optional, defaults to'exa'; set to'tavily'to use Tavily
Notes for reviewers
- Exa dependency (
exa-js) andEXA_SEARCH_API_KEYare fully preserved - The
SearchResulttype 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/coredependency is added topackage.json, lazy client initialization andtavilySearch()wrapper are implemented consistently with the existing Exa pattern inservices.ts, thesearch()function inresearch-functions.tscorrectly branches onSEARCH_PROVIDERenv var defaulting to"exa", and.env.exampledocuments both new variables. Exa functionality is fully preserved. The only notable issue is an unintendedpackage-lock.jsonbeing committed to a project that uses bun (abun.lockalready exists), which is a minor inconsistency and should be removed.