跳转到主要内容

MDXSearchTool

MDXSearchTool 正在持续开发中。在我们完善工具的过程中,功能可能会增加或删除,其功能也可能发生无法预料的变化。

描述

MDX 搜索工具是 crewai_tools 包的一个组件,旨在促进高级 Markdown 语言提取。它使用户能够通过基于查询的搜索,有效地从 MD 文件中搜索和提取相关信息。此工具对于数据分析、信息管理和研究任务非常有价值,简化了在大型文档集合中查找特定信息的过程。

安装

在使用 MDX 搜索工具之前,请确保已安装 crewai_tools 包。如果尚未安装,您可以使用以下命令进行安装。
pip install 'crewai[tools]'

使用示例

要使用 MDX 搜索工具,您必须首先设置必要的环境变量。然后,将该工具集成到您的 crewAI 项目中,以开始您的市场研究。以下是一个如何执行此操作的基本示例。
代码
from crewai_tools import MDXSearchTool

# Initialize the tool to search any MDX content it learns about during execution
tool = MDXSearchTool()

# OR

# Initialize the tool with a specific MDX file path for an exclusive search within that document
tool = MDXSearchTool(mdx='path/to/your/document.mdx')

参数

  • mdx:可选。指定用于搜索的 MDX 文件路径。可以在初始化时提供。

自定义模型和嵌入

该工具默认使用 OpenAI 进行嵌入和摘要。要进行自定义,请使用如下所示的配置字典。
代码
tool = MDXSearchTool(
    config=dict(
        llm=dict(
            provider="ollama", # Options include google, openai, anthropic, llama2, etc.
            config=dict(
                model="llama2",
                # Optional parameters can be included here.
                # 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",
                # Optional title for the embeddings can be added here.
                # title="Embeddings",
            ),
        ),
    )
)