CSVSearchTool

实验性:我们仍在改进工具,因此未来可能会出现意外行为或变化。

描述

此工具用于在CSV文件内容中执行RAG(检索增强生成)搜索。它允许用户在指定CSV文件的内容中进行语义搜索查询。 此功能特别适用于从大型CSV数据集中提取信息,传统搜索方法可能效率低下。所有名称中包含“搜索”的工具,包括CSVSearchTool, 都是为搜索不同数据源而设计的RAG工具。

安装

安装crewai_tools包

pip install 'crewai[tools]'

示例

Code
from crewai_tools import CSVSearchTool

# Initialize the tool with a specific CSV file. 
# This setup allows the agent to only search the given CSV file.
tool = CSVSearchTool(csv='path/to/your/csvfile.csv')

# OR

# Initialize the tool without a specific CSV file. 
# Agent will need to provide the CSV path at runtime.
tool = CSVSearchTool()

参数

以下参数可用于自定义CSVSearchTool的行为:

参数类型描述
csvstring可选. 要搜索的CSV文件的路径。如果工具初始化时没有指定特定的CSV文件,则这是一个必需的参数;否则,它是可选的。

自定义模型和嵌入

默认情况下,该工具使用OpenAI进行嵌入和摘要生成。要自定义模型,您可以使用如下配置字典:

Code
tool = CSVSearchTool(
    config=dict(
        llm=dict(
            provider="ollama", # or google, openai, anthropic, llama2, ...
            config=dict(
                model="llama2",
                # temperature=0.5,
                # top_p=1,
                # stream=true,
            ),
        ),
        embedder=dict(
            provider="google", # or openai, ollama, ...
            config=dict(
                model="models/embedding-001",
                task_type="retrieval_document",
                # title="Embeddings",
            ),
        ),
    )
)

这个页面有帮助吗?