-
Notifications
You must be signed in to change notification settings - Fork 8
feat(ai_chat): add Tavily search plugin #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3
Are you sure you want to change the base?
Conversation
…in: tavily_search using tavily-python client (lazy import)\n- Config model: TavilySearchConfig with api_key/search_depth/max_results options\n- Registered in ALL_PLUGINS; default disabled until api_key provided\n- Compile check: passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new Tavily search plugin to the AI Chat module, providing AI-powered web search capabilities. Tavily is a search engine specifically designed for AI applications.
Key changes:
- Implements a new
TavilySearchPluginwith comprehensive configuration options including search depth, result limits, and content inclusion settings - Adds lazy loading of the
tavily-pythondependency to avoid hard requirements - Registers the plugin in the central plugins registry for availability in the AI chat system
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
modules/self_contained/ai_chat/plugins/tavily_search.py |
New plugin implementation with config model, search functionality, and error handling |
modules/self_contained/ai_chat/plugins_registry.py |
Registers the new Tavily search plugin in the system |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| try: | ||
| max_results = int(params.get("max_results", self.config.max_results)) | ||
| except Exception: |
Copilot
AI
Sep 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using bare Exception is too broad. Consider catching specific exceptions like ValueError or TypeError for the int() conversion to provide more precise error handling.
| except Exception: | |
| except (ValueError, TypeError): |
| # 懒加载 tavily 依赖 | ||
| try: | ||
| from tavily import TavilyClient # type: ignore | ||
| except Exception: |
Copilot
AI
Sep 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using bare Exception is too broad. Consider catching ImportError or ModuleNotFoundError specifically since this is handling import failures.
| except Exception: | |
| except (ImportError, ModuleNotFoundError): |
|
|
||
| try: | ||
| resp: dict[str, Any] = await asyncio.to_thread(_search) | ||
| except Exception as e: # 网络或鉴权错误 |
Copilot
AI
Sep 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using bare Exception is too broad. Consider catching specific exceptions that the Tavily client might raise, such as authentication errors, network timeouts, or API-specific exceptions to provide more targeted error messages.
This PR adds a new AI Chat plugin: Tavily – a search engine purpose-built for AI.
Summary:
tavily_searchimplemented inmodules/self_contained/ai_chat/plugins/tavily_search.pyTavilySearchConfigwith fields:api_key(required),search_depth(basic/advanced),max_results,include_answer,include_raw_contenttavily-pythonto avoid hard dependency unless the plugin is enabledplugins_registry.pyapi_keyindata/ai_chat/ai_chat.jsonNotes:
uv add tavily-pythonpython -m compileallpassed.Please review. Once merged, I can follow up with docs and tests if desired.
Pull Request opened by Augment Code with guidance from the PR author