feat: migrate general & news search to support Tavily alongside DDG#91
Open
tavily-integrations wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Tavily as an opt-in, parallel search provider alongside the existing DuckDuckGo paths in general web search, DDG fallback, and news search modules. Tavily is activated only when the
TAVILY_API_KEYenvironment variable is set — existing behavior is fully preserved when the key is absent.What changed
config/settings.py— AddedTAVILY_API_KEYconfig var (read fromos.environ, defaults to empty string)requirements.txt— Addedtavily-python>=0.5.0,<1.0dependencygeneralsearch.py— Added_tavily_text()async helper and_normalize_tavily()normalizer; Tavily results are merged (deduplicated by URL) into the result set before the DDG fallback branchddg_fallback.py— Added_tavily_search()sync helper;search_ddg()now tries Tavily first when the API key is present, falling through to DDG on failure or missing keynews.py— Added_tavily_news()async method and_normalize_tavily_news()normalizer insideNewsHandler; Tavily news runs in parallel with SearXNG viaasyncio.gather, with results merged before the DDG news pathDependency changes
tavily-python>=0.5.0,<1.0torequirements.txtEnvironment variable changes
TAVILY_API_KEY— when set to a valid Tavily API key, enables Tavily search; when empty/unset, all existing DDG code paths remain activeNotes for reviewers
asyncio.to_thread()since the Python SDK is synchronousTAVILY_API_KEYis not set🤖 Generated with Claude Code
Automated Review
if _TAVILY_API_KEY) ensures zero behavior change when the key is absent. Error handling is consistent (try/except returning []) and imports are lazy, preventingImportErrorregressions. Three minor issues found: (1) the Tavily path in generalsearch.py is labeled "parallel" but runs sequentially after SearXNG; (2)import os as _osis placed mid-file; (3) large swaths of whitespace-only diff churn (trailing-space normalization) unrelated to the migration. None of these block approval.