CSVSearchTool
实验性功能:我们仍在努力改进工具,因此未来可能会出现意外行为或变更。
此工具用于在 CSV 文件内容中执行 RAG(检索增强生成)搜索。它允许用户在指定 CSV 文件的内容中对查询进行语义搜索。当从大型 CSV 数据集中提取信息时,此功能特别有用,因为传统搜索方法可能效率低下。所有名称中带有“Search”的工具,包括 CSVSearchTool,都是为搜索不同数据源而设计的 RAG 工具。
安装 crewai_tools 包
pip install 'crewai[tools]'
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 的行为
| 参数 | 类型 | 描述 |
|---|
| csv | 字符串 | 可选。您要搜索的 CSV 文件的路径。如果工具在初始化时未指定 CSV 文件,则此参数为必需参数;否则为可选参数。 |
自定义模型和嵌入
默认情况下,该工具使用 OpenAI 进行嵌入和摘要。要自定义模型,您可以使用如下所示的配置字典:
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",
),
),
)
)