跳转到内容

网站 RAG 搜索

WebsiteSearchTool 被设计为用于在网站内容中进行语义搜索的一个概念。
它旨在利用检索增强生成(RAG)等高级机器学习模型,高效浏览并从指定 URL 中提取信息。
该工具希望提供灵活性,让用户既可以跨任意网站进行搜索,也可以聚焦于感兴趣的特定网站。
请注意,WebsiteSearchTool 的当前实现细节仍在开发中,所描述的功能可能尚不可用。

为了在 WebsiteSearchTool 可用后迅速开始使用,你可以先安装基础包:

Terminal window
pip install 'crewai[tools]'

该命令会安装必要的依赖,确保工具完全集成后用户可以立即开始使用。

下面是 WebsiteSearchTool 在不同场景下可能的用法。请注意,这些示例仅用于说明,代表的是规划中的功能:

from crewai_tools import WebsiteSearchTool
# 初始化一个工具,智能体可用于
# 搜索任意发现到的网站
tool = WebsiteSearchTool()
# 将搜索限制为某个特定网站的内容,
# 这样智能体只能在该网站内搜索
tool = WebsiteSearchTool(website='https://example.com')
  • website:用于指定网站 URL 以便聚焦搜索的可选参数。该参数旨在增强工具灵活性,以便在需要时执行定向搜索。

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

tool = WebsiteSearchTool(
config=dict(
llm=dict(
provider="ollama", # 或 google、openai、anthropic、llama2 等
config=dict(
model="llama2",
# temperature=0.5,
# top_p=1,
# stream=true,
),
),
embedder=dict(
provider="google-generativeai", # 或 openai、ollama 等
config=dict(
model_name="gemini-embedding-001",
task_type="RETRIEVAL_DOCUMENT",
# title="Embeddings",
),
),
)
)