DOCXSearchTool

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

描述

DOCXSearchTool 是一个为DOCX文档中的语义搜索设计的RAG工具。 它使用户能够通过基于查询的搜索有效地从DOCX文件中搜索和提取相关信息。 该工具对于数据分析、信息管理和研究任务非常宝贵, 简化了在大量文档集合中查找特定信息的过程。

安装

在终端中运行以下命令来安装crewai_tools包:

pip install 'crewai[tools]'

示例

以下示例演示了如何初始化DOCXSearchTool以在任何DOCX文件的内容中搜索或使用特定的DOCX文件路径进行搜索。

Code
from crewai_tools import DOCXSearchTool

# Initialize the tool to search within any DOCX file's content
tool = DOCXSearchTool()

# OR

# Initialize the tool with a specific DOCX file, 
# so the agent can only search the content of the specified DOCX file
tool = DOCXSearchTool(docx='path/to/your/document.docx')

参数

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

参数类型描述
docxstring可选. 一个参数,指定要搜索的DOCX文件的路径。如果在初始化期间未提供,该工具允许稍后指定任何DOCX文件的内容路径进行搜索。

自定义模型和嵌入

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

Code
tool = DOCXSearchTool(
    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",
            ),
        ),
    )
)

这个页面有帮助吗?