Skip to content

feat: migrate search handler to support Tavily alongside DuckDuckGo#2

Open
tavily-integrations wants to merge 1 commit into239x1a3242-maker:mainfrom
tavily-integrations:feat/tavily-migration/ai-agent-duckduckgo-to-tavily
Open

feat: migrate search handler to support Tavily alongside DuckDuckGo#2
tavily-integrations wants to merge 1 commit into239x1a3242-maker:mainfrom
tavily-integrations:feat/tavily-migration/ai-agent-duckduckgo-to-tavily

Conversation

@tavily-integrations
Copy link
Copy Markdown

Summary

  • Added tavily-python dependency alongside existing duckduckgo-search in requirements.txt
  • Implemented tavily_web_search() in server-fetch.py that calls TavilyClient.search() and normalizes results to the same dict shape as DuckDuckGo results
  • Added _get_search_provider() helper that reads SEARCH_PROVIDER env var; defaults to tavily when TAVILY_API_KEY is set, otherwise falls back to DuckDuckGo
  • Updated Fetcher.web_search to dispatch to Tavily or DuckDuckGo based on configured provider
  • Added TAVILY_API_KEY and SEARCH_PROVIDER to .env.example with documentation
  • Added __pycache__/ and *.pyc to .gitignore

Files changed

  • requirements.txt — added tavily-python==0.5.0
  • backend/tools/server-fetch.py — Tavily import, search function, provider dispatch
  • .env.example — new env var documentation
  • .gitignore — ignore Python bytecode artifacts

Dependency changes

  • Added tavily-python==0.5.0 to requirements.txt

Env var changes

  • Added TAVILY_API_KEY (required when using Tavily provider)
  • Added SEARCH_PROVIDER (optional; values: tavily | duckduckgo)

Notes for reviewers

  • DuckDuckGo code path is fully preserved — no existing functionality is removed
  • Tavily import is soft (try/except) matching the existing DDGS import pattern
  • Provider auto-selects Tavily when TAVILY_API_KEY is present; explicit SEARCH_PROVIDER overrides

🤖 Generated with Claude Code

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The migration is correct and complete. Tavily is added as an additive, configurable parallel provider alongside DuckDuckGo with no regressions. The soft-import pattern, env var dispatch logic, result normalization, and dependency additions are all implemented correctly. Four minor issues are noted but none block approval.

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