Skip to content

Add Tavily option for deep-research-exa-additive#7

Open
evanYDL wants to merge 1 commit intocodebucks27:mainfrom
evanYDL:tavily-migration/deep-research-exa-additive
Open

Add Tavily option for deep-research-exa-additive#7
evanYDL wants to merge 1 commit intocodebucks27:mainfrom
evanYDL:tavily-migration/deep-research-exa-additive

Conversation

@evanYDL
Copy link

@evanYDL evanYDL commented Mar 5, 2026

Search Provider Migration: deep-research-exa-additive

Adds Tavily as an additional option while preserving existing provider behavior.

Introduces Tavily, a search API optimized for LLM applications.

Changes

All changes are complete and consistent. Here's a summary:

Changes Made

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

  • Added import { tavily } from "@tavily/core"
  • Added lazy-init getTavily() function mirroring the existing getExa() pattern — creates a Tavily client on first call using TAVILY_API_KEY env var

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

  • Added getTavily to imports from ./services
  • Extracted existing Exa search logic into a private searchWithExa() helper
  • Added new searchWithTavily() helper that calls client.search() with searchDepth: "advanced", maxResults: MAX_SEARCH_RESULTS, and excludeDomains: ["youtube.com"]; filters results by score > 0 and maps to the shared SearchResult shape
  • Modified search() to branch on SEARCH_PROVIDER env var:
    • "exa" (default) — uses Exa as before
    • "tavily" — uses Tavily
    • "both" — runs both in parallel via Promise.all, merges and deduplicates by URL

3. package.json

  • Added "@tavily/core": "^0.0.7" to dependencies (kept exa-js)

4. .env.example

  • Added TAVILY_API_KEY='add your tavily api key here'
  • Added SEARCH_PROVIDER='exa' with comment documenting options: exa | tavily | both
  • Kept existing EXA_SEARCH_API_KEY

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