Skip to content

feat: add Tavily search provider alongside Google Custom Search#4

Open
tavily-integrations wants to merge 1 commit into
hashan-7:mainfrom
Tavily-FDE:feat/tavily-migration/queryweave-google-to-tavily
Open

feat: add Tavily search provider alongside Google Custom Search#4
tavily-integrations wants to merge 1 commit into
hashan-7:mainfrom
Tavily-FDE:feat/tavily-migration/queryweave-google-to-tavily

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

  • Added Tavily Search REST API as a configurable alternative to Google Custom Search in SearchService
  • New search.provider property (google or tavily, defaults to google) controls which provider is used
  • When Tavily is active, raw_content from the API response is used directly, bypassing Jsoup scraping
  • Added automatic Tavily fallback: if Google returns no results and tavily.api.key is configured, Tavily is tried automatically
  • Google Custom Search path remains completely unchanged

Files changed

  • src/main/java/org/example/aisearchapp/service/SearchService.java — Added tavilyApiKey and searchProvider fields, searchTavily() method, and provider branching in getAiSummary()
  • src/main/resources/application.properties.example — Added search.provider and tavily.api.key properties

Dependency changes

  • No new JAR dependencies — Tavily REST API is consumed via the existing RestTemplate and ObjectMapper

Environment variable changes

  • TAVILY_API_KEY → maps to tavily.api.key Spring property
  • SEARCH_PROVIDER → maps to search.provider (values: google or tavily, default google)

Notes for reviewers

  • The Tavily API is called with include_raw_content=true and max_results=5 to match the existing Google path's behavior
  • Blocked source filtering (isBlockedSource) is applied to Tavily results as well
  • Content is truncated to 4000 chars per result, consistent with the existing scraping logic

🤖 Generated with Claude Code

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The migration is functionally correct and well-scoped. Tavily is called via a proper POST to https://api.tavily.com/search with valid parameters (api_key, query, include_raw_content, max_results), and the response is parsed correctly using results[].url and results[].raw_content. The additive strategy is cleanly implemented — Google+Jsoup is the preserved default, Tavily is an opt-in provider via search.provider=tavily, and a Google-to-Tavily fallback is added when Google returns empty results. application.properties.example is updated with the two new properties and a helpful comment. No regressions, no dead code, no broken imports. Three minor issues found 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