FileReadTool

我们仍在努力改进工具,因此未来可能会出现意外的行为或更改。

描述

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:您要读取的文件路径。它接受绝对路径和相对路径。请确保文件存在并且您具有访问它所需的权限。