Skip to content

feat: add Tavily search provider to ChuanhuAgent#1193

Open
mani2001 wants to merge 1 commit intoGaiZhenbiao:mainfrom
mani2001:feat/tavily-migration/chuanhu-agent-search-tavily
Open

feat: add Tavily search provider to ChuanhuAgent#1193
mani2001 wants to merge 1 commit intoGaiZhenbiao:mainfrom
mani2001:feat/tavily-migration/chuanhu-agent-search-tavily

Conversation

@mani2001
Copy link
Copy Markdown

Summary

  • Added Tavily as a configurable, optional search provider in ChuanhuAgent alongside existing DuckDuckGo, Google CSE, and SerpAPI providers
  • When TAVILY_API_KEY is set (via env var or config.json), a TavilySearchResults tool is registered in the agent's tool list, letting the LLM choose it for web searches
  • All existing search providers remain unchanged (additive migration)

Files Changed

  • requirements.txt — Added tavily-python dependency
  • config_example.json — Added TAVILY_API_KEY field in the ChuanhuAgent settings section with comment
  • modules/config.py — Added TAVILY_API_KEY to the env-var propagation loop (line 212)
  • modules/models/ChuanhuAgent.py — Added Tavily tool registration block after SerpAPI, with import, instantiation of TavilySearchResults(max_results=5), and appropriate logging

Dependency Changes

  • Added tavily-python to requirements.txt

Environment Variable Changes

  • Added TAVILY_API_KEY — optional, used to enable Tavily search in ChuanhuAgent

Notes for Reviewers

  • This is an additive change: DuckDuckGo remains the zero-config fallback; Google CSE, SerpAPI, and Tavily are all optional
  • The TavilySearchResults tool is imported from langchain_community.tools.tavily_search, which requires tavily-python as a backend
  • Import is done lazily inside the conditional block to avoid import errors when the package is not installed

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is clean, minimal, and additive. All four reported files are correctly modified, the implementation follows existing provider patterns faithfully, no regressions are introduced, and no unrelated changes are present. Two minor issues exist: an empty-string API key edge case (consistent with the existing codebase behavior for other providers) and a missing version pin on the new dependency (also consistent with langchain_community being unpinned).

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