Open
Conversation
新增 enable_searxng_search 网页搜索工具
Owner
|
关于工具方面,我觉得对于内置工具可以更加克制一点。如果搜索工具比较多的话,可能会比较杂,我不希望把这里的工具做成菜市场一样。 后续关于工具的设计,更倾向于仅提供基础能力。所以对于搜索类工具,我的想法是,这个方案可能不会合入到主线里面,现在搜索工具使用的是 Tavily,后续我们可以通过环境变量来控制具体使用哪种搜索服务(如 Tavily 或 SearXNG)。 比如在这里,使用环境变量来控制返回 tavily 还是 searxng # 注册 TavilySearch 工具(延迟初始化)
def _register_tavily_tool():
"""Register TavilySearch tool with extra metadata."""
tavily_instance = _create_tavily_search()
# 手动注册到全局注册表
_extra_registry["tavily_search"] = ToolExtraMetadata(
category="buildin",
tags=["搜索"],
display_name="Tavily 网页搜索",
)
# 添加到工具实例列表
_all_tool_instances.append(tavily_instance)这样对其他部分的业务模块的影响最小。就是工具名可能需要修改为 WebSearch |
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.
新增 enable_searxng_search 网页搜索工具
变更描述
变更类型
测试
相关日志或者截图
说明
SearXNG 的 score 是相对分数(同一查询内各结果之间的相关度对比),不是绝对准确度。最高结果永远是 1.0,后续结果按相关度比例递减。但是没有像Tavily的api限制,也可以根据searxng的官方文档配置对应的搜索引擎和策略;当前测试google,bing,duckduckgo比较稳定,其他搜索引擎(比如mojeek 和 qwant 引擎(被目标网站临时封禁))可能会因为网络不稳定报403错误,不过就算错误ERROR由 SearXNG 内部抛出,不影响上层工具的正常工作。
截图测试