PDFSearchTool

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

描述

PDFSearchTool 是一个 RAG 工具,专为在 PDF 内容中进行语义搜索而设计。它允许输入搜索查询和 PDF 文档,利用先进的搜索技术高效地找到相关内容。 这一功能使其特别适用于从大型 PDF 文件中快速提取特定信息。

安装

要开始使用PDFSearchTool,首先确保安装了crewai_tools包,使用以下命令:

pip install 'crewai[tools]'

示例

以下是使用PDFSearchTool在PDF文档中搜索的方法:

Code
from crewai_tools import PDFSearchTool

# Initialize the tool allowing for any PDF content search if the path is provided during execution
tool = PDFSearchTool()

# OR

# Initialize the tool with a specific PDF path for exclusive search within that document
tool = PDFSearchTool(pdf='path/to/your/document.pdf')

参数

  • pdf: 可选 用于搜索的PDF路径。可以在初始化时提供,也可以在run方法的参数中提供。如果在初始化时提供,工具将限制其搜索范围到指定的文档。

自定义模型和嵌入

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

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

这个页面有帮助吗?