Skip to content

feat: add Tavily as parallel search provider alongside SearXNG#10

Open
tavily-integrations wants to merge 1 commit into
Smilin01:masterfrom
Tavily-FDE:feat/tavily-migration/aetheron-searxng-to-tavily-additive
Open

feat: add Tavily as parallel search provider alongside SearXNG#10
tavily-integrations wants to merge 1 commit into
Smilin01:masterfrom
Tavily-FDE:feat/tavily-migration/aetheron-searxng-to-tavily-additive

Conversation

@tavily-integrations
Copy link
Copy Markdown

Summary

Adds Tavily as a configurable, additive search provider in the search API route. When TAVILY_API_KEY is set, Tavily is used as the primary search source; if it returns no useful results, the existing SearXNG pipeline is used as a fallback. When the env var is absent, behavior is completely unchanged (SearXNG only).

What changed

  • src/app/api/search/route.ts: Added searchTavily() function that calls the Tavily REST API via fetch (edge-runtime compatible) and maps results to the existing SearchResult interface. Modified webSearch() to use Tavily as primary when TAVILY_API_KEY is present, with automatic SearXNG fallback.
  • package.json: Added @tavily/core as a runtime dependency.
  • README.md: Documented TAVILY_API_KEY env var in the environment setup section.

Files changed

  • src/app/api/search/route.ts
  • package.json
  • README.md

Dependency changes

  • Added @tavily/core ^0.6.1 to package.json dependencies

Environment variable changes

  • Added optional TAVILY_API_KEY — enables Tavily as primary search provider when present

Notes for reviewers

  • The Tavily REST API is called directly via fetch rather than through the @tavily/core SDK to ensure edge runtime compatibility (export const runtime = 'edge').
  • All existing SearXNG code, config, and env vars remain untouched.
  • Tavily search depth is set to "advanced" for initial queries and "basic" for follow-ups, matching the existing SearXNG strategy pattern.
  • The topic parameter maps isCurrentEvents to Tavily's "news" topic for better results on current events queries.

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The additive Tavily migration is functionally correct, properly scoped, and preserves backward compatibility. The implementation correctly uses native fetch against the Tavily REST API for edge runtime compatibility (the route exports runtime = 'edge'), the fallback logic to SearXNG is sound, and existing SearXNG-only behavior is completely unchanged when TAVILY_API_KEY is absent. The main concern is that @tavily/core was added to package.json but is never imported — the implementation explicitly chose fetch over the SDK for edge compatibility, making the SDK dependency dead weight. This is worth cleaning up but doesn't cause any runtime failure or regression since Next.js only restricts what is imported, not what exists in node_modules. The package-lock.json changes also include cosmetic "peer": true flag removals unrelated to Tavily, which are harmless lock-file normalization artifacts from running npm install.

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