feat: 集成 You.com 网络搜索 API 作为 LangGraph Agent 工具 - #73
Open
tra371 wants to merge 1 commit into
Open
Conversation
- 新增 YoucomSearchClient (providers/youcom.py):httpx.AsyncClient 调用 YDC Index API,429/401/其他错误均优雅降级,不影响主流程。 - 新增 search_web LangGraph 工具 (graph/tools/youcom_search.py):Agent 可在内部知识库无法满足时从互联网检索实时信息。 - config.py 新增 YOUCOM_API_KEY、YOUCOM_SEARCH_ENABLED、YOUCOM_SEARCH_TOP_K 三个配置项,默认关闭。 - prompts.py 系统提示词新增第七条规则,指导 Agent 在需要实时信息时 调用 search_web。 - lifecycle manager shutdown 钩子新增 youcom_search_client.aclose()。 - .env.example 新增 §8.1 You.com Search 配置块。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
针对该问题的实现 - #72 |
Owner
|
ok,增加mcp的时候我会看看 |
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.
概述
为 CatWiki LangGraph ReAct Agent 新增
search_web工具,通过 You.com Search API(https://ydc-index.io/v1/search)从互联网检索信息,作为内部知识库检索的补充通道。主要改动
YoucomSearchClient(app/core/ai/providers/youcom.py):基于httpx.AsyncClient的 You.com API 客户端,429(限流)/401(认证失败)/其他错误均静默降级,不影响主流程。search_web工具(app/core/ai/graph/tools/youcom_search.py):LangGraph@tool,Agent 在内部知识库无法满足时调用,检索实时信息。config.py/.env.example):YOUCOM_API_KEY— API 密钥YOUCOM_SEARCH_ENABLED— 是否启用(默认 false)YOUCOM_SEARCH_TOP_K— 每次搜索返回结果数(默认 10)prompts.py):新增第七条规则,指导 Agent 在需要实时资讯时调用search_web。lifecycle/manager.py):shutdown 时关闭 You.com 客户端连接。测试建议
YOUCOM_API_KEY和YOUCOM_SEARCH_ENABLED=truesearch_web被调用YOUCOM_SEARCH_ENABLED=false时,Agent 行为不受影响涉及的代码位置
app/core/ai/providers/youcom.pyapp/core/ai/graph/tools/__init__.pyapp/core/ai/graph/tools/youcom_search.pyapp/core/ai/graph/logic.py— 工具注册app/core/ai/prompts.py— 提示词app/core/infra/config.py— 配置项app/core/lifecycle/manager.py— 客户端关闭.env.example— 配置模板