示例

Searxng 使 Agent 能够搜索网络进行查询、抓取网站或爬取网站。

cookbook/tools/searxng_tools.py
from agno.agent import Agent
from agno.tools.searxng import SearxngTools

# 使用你的 Searxng 实例 URL 初始化 Searxng
searxng = SearxngTools(
    host="http://localhost:53153",
    engines=[],
    fixed_max_results=5,
    news=True,
    science=True
)

# 使用 Searxng 创建一个 Agent
agent = Agent(tools=[searxng])

# 示例:让 Agent 使用 Searxng 进行搜索
agent.print_response("""
请搜索关于人工智能的信息,
并总结主要结果中的关键点。
""")

Toolkit 参数

参数类型默认值描述
hoststr-连接的主机。
enginesList[str][]要使用的搜索引擎列表。
fixed_max_resultsintNone指定固定最大结果数的可选参数。
imagesboolFalse启用图片搜索。
itboolFalse启用 IT 相关内容搜索。
mapboolFalse启用地图搜索。
musicboolFalse启用音乐搜索。
newsboolFalse启用新闻搜索。
scienceboolFalse启用科学相关内容搜索。
videosboolFalse启用视频搜索。

Toolkit 函数

函数描述
search使用指定的查询执行常规网络搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回搜索结果。
image_search使用指定的查询执行图片搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回图片搜索结果。
it_search使用指定的查询执行 IT 相关信息搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回 IT 相关搜索结果。
map_search使用指定的查询执行地图搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回地图搜索结果。
music_search使用指定的查询执行音乐相关信息搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回音乐搜索结果。
news_search使用指定的查询执行新闻搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回新闻搜索结果。
science_search使用指定的查询执行科学相关信息搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回科学相关搜索结果。
video_search使用指定的查询执行视频搜索。参数包括搜索词的 query 和结果最大数的 max_results(默认为 5)。返回视频搜索结果。

开发者资源