FileTools 使代理能够读取和写入本地文件系统上的文件。

示例

下面的代理将生成一个答案并将其保存在文件中。

cookbook/tools/file_tools.py
from agno.agent import Agent
from agno.tools.file import FileTools

agent = Agent(tools=[FileTools()], show_tool_calls=True)
agent.print_response("What is the most advanced LLM currently? Save the answer to a file.", markdown=True)

Toolkit 参数

名称类型默认值描述
base_dirPath-指定文件操作的基础目录路径。
save_filesboolTrue确定在操作过程中是否应保存文件。
read_filesboolTrue允许在操作过程中从文件中读取。
list_filesboolTrue启用列出指定目录中的文件。

Toolkit 函数

名称描述
save_file将内容保存到名为 file_name 的文件中,如果成功则返回文件名。
read_file读取 file_name 文件的内容,如果成功则返回内容。
list_files返回基础目录中的文件列表

开发者资源