跳转到主要内容

概述

我们仍在努力改进工具,因此未来可能会出现意外行为或变更。
FileReadTool 在概念上代表了 crewai_tools 包中的一套功能,旨在促进文件读取和内容检索。该套件包括用于处理批量文本文件、读取运行时配置文件以及导入数据进行分析的工具。它支持多种基于文本的文件格式,如 .txt.csv.json 等。根据文件类型,该套件提供专门的功能,例如将 JSON 内容转换为 Python 字典以便于使用。

安装

要使用先前归属于 FileReadTool 的功能,请安装 crewai_tools 包。
pip install 'crewai[tools]'

用法示例

开始使用 FileReadTool
代码
from crewai_tools import FileReadTool

# Initialize the tool to read any files the agents knows or lean the path for
file_read_tool = FileReadTool()

# OR

# Initialize the tool with a specific file path, so the agent can only read the content of the specified file
file_read_tool = FileReadTool(file_path='path/to/your/file.txt')

参数

  • file_path:您要读取的文件的路径。它接受绝对路径和相对路径。请确保文件存在并且您拥有访问该文件所需的权限。