BraveSearch 允许 Agent 使用 Brave 搜索引擎在网上搜索信息。

前提条件

以下示例需要 brave-search 库。

pip install -U brave-search
export BRAVE_API_KEY=***

示例

cookbook/tools/bravesearch_tools.py
from agno.agent import Agent
from agno.tools.bravesearch import BraveSearchTools

agent = Agent(
    tools=[BraveSearchTools()],
    description="你是一个新闻助手,帮助用户找到最新新闻。",
    instructions=[
        "根据用户提供的主题,回应该主题的 4 条最新新闻。"
    ],
    show_tool_calls=True,
)
agent.print_response("AI 代理", markdown=True)

工具包参数

参数类型默认值描述
fixed_max_resultsintNone可选的固定最大返回结果数。
fixed_languagestrNone可选的固定请求语言。

工具包函数

函数描述
brave_search使用 Brave 搜索指定查询。参数包括用于搜索词的 query,用于最大结果数的 max_results(默认为 5),用于搜索结果地理区域的 country(默认为 “US”)以及用于搜索结果语言的 language(默认为 “en”)。将搜索结果以 JSON 格式字符串形式返回。

开发者资源