> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 文件

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

## 示例

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

```python cookbook/tools/file_tools.py theme={null}
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_dir`   | `Path` | -      | 指定文件操作的基础目录路径。   |
| `save_files` | `bool` | `True` | 确定在操作过程中是否应保存文件。 |
| `read_files` | `bool` | `True` | 允许在操作过程中从文件中读取。  |
| `list_files` | `bool` | `True` | 启用列出指定目录中的文件。    |

## Toolkit 函数

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

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/file.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/file_tools.py)
