Skip to content

feat: add Tavily as configurable search provider alongside Serper#70

Open
tavily-integrations wants to merge 1 commit into
precious112:mainfrom
Tavily-FDE:feat/tavily-migration/core-serper-to-tavily-additive
Open

feat: add Tavily as configurable search provider alongside Serper#70
tavily-integrations wants to merge 1 commit into
precious112:mainfrom
Tavily-FDE:feat/tavily-migration/core-serper-to-tavily-additive

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily as a configurable search provider option alongside the existing Serper integration. When a user provides a Tavily API key, the system routes search calls through the Tavily SDK; otherwise it falls back to Serper. No existing Serper code is removed.

Changes

Core (Python)

  • core/src/tools/tavily_tool.py (new): TavilyTool class implementing the same search(query, k) -> List[Dict] interface as SerperTool, using the tavily-python SDK
  • core/src/agents/researcher_agent.py: Added tavily_api_key parameter; selects TavilyTool or SerperTool at instantiation; renamed internal serper_tool to search_tool
  • core/src/tools/illustration_tool.py: Constructor now accepts a generic search_tool parameter instead of SerperTool-specific type
  • core/src/worker.py: Extracts tavilyApiKey from task config and passes it through to ResearcherAgent
  • core/src/config.py: Added TAVILY_API_KEY env var
  • core/pyproject.toml: Added tavily-python>=0.5.0 dependency

Client (TypeScript/React)

  • client/store/useSettingsStore.ts: Added tavily field to ApiKeys interface
  • client/components/settings-dialog.tsx: Added Tavily API Key input field
  • client/lib/api.ts: Added tavilyApiKey parameter to sendMessage
  • client/app/chat/page.tsx: Passes tavilyApiKey from settings to sendMessage
  • client/app/chat/[chatId]/page.tsx: Passes tavilyApiKey from settings to sendMessage

API (TypeScript/Express)

  • api/src/modules/chat/chat.validation.ts: Added tavilyApiKey to message request schema
  • api/src/modules/chat/chat.controller.ts: Extracts tavilyApiKey from request body
  • api/src/modules/chat/chat.service.ts: Added tavilyApiKey to config type (flows into Redis payload)

Infrastructure

  • k8s/secrets.template.yaml: Added TAVILY_API_KEY secret entry
  • .gitignore: Added Python cache entries (__pycache__/, *.pyc)

Dependency changes

  • Added tavily-python>=0.5.0 to core/pyproject.toml

Environment variable changes

  • Added TAVILY_API_KEY (optional) — existing SERPER_API_KEY remains unchanged

Notes for reviewers

  • This is an additive migration: Serper remains the default when no Tavily key is provided
  • The TavilyTool uses search_depth="basic" for cost efficiency; can be tuned later
  • IllustrationTool image search is already deactivated, so the type change to generic search_tool has no functional impact

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is well-structured and correct end-to-end. The full propagation chain — client settings store → settings dialog → API lib → chat pages → validation → controller → service → Redis payload → worker → ResearcherAgent → TavilyTool — is consistently implemented. The TavilyTool correctly implements the same search(query, k) interface as SerperTool, the fallback logic (Tavily when key present, Serper otherwise) is sound, the dependency is added to pyproject.toml, the env var is documented in Config and k8s secrets, and there are no broken imports or regressions. Only minor issues were found.

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