使用工具包
Agno 提供了许多预构建的工具包,你可以将它们添加到你的代理中。例如,让我们使用 DuckDuckGo 工具包来搜索网页。编写自己的工具
为了获得更多控制权,你可以编写自己的 Python 函数并将它们作为工具添加到代理中。例如,这是如何将get_top_hackernews_stories 工具添加到代理的方法。
hn_agent.py
属性
以下属性允许Agent 使用工具
| 参数 | 类型 | 类型 | 默认值 | 描述 |
|-----------|------|---------|-------------|
| tools | List[Union[Tool, Toolkit, Callable, Dict, Function]] | List[Union[Tool, Toolkit, Callable, Dict, Function]] | - | 提供给模型的工具列表。工具是模型可能为其生成 JSON 输入的函数。 |
| show_tool_calls | bool | bool | False | 在模型响应中打印工具调用的签名。 |
| tool_call_limit | int | int | - | 单次运行允许的最大工具调用次数。 |
| tool_choice | Union[str, Dict[str, Any]] | Union[str, Dict[str, Any]] | - | 控制模型调用的工具(如果有)。“none” 表示模型不会调用工具,而是生成消息。“auto” 表示模型可以在生成消息或调用工具之间进行选择。通过 {"type": "function", "function": {"name": "my_function"}} 指定特定函数会强制模型调用该工具。“none” 是在没有工具存在时的默认设置。“auto” 是存在工具时的默认设置。 |
| read_chat_history | bool | bool | False | 添加一个允许模型读取聊天记录的工具。 |
| search_knowledge | bool | bool | False | 添加一个允许模型搜索知识库(又名 Agentic RAG)的工具。 |
| update_knowledge | bool | bool | False | 添加一个允许模型更新知识库的工具。 |
| read_tool_call_history | bool | bool | False | 添加一个允许模型获取工具调用历史记录的工具。 |
开发者资源
- 查看食谱