跳转到主要内容
知识库通过两个 Agent 工具与 DeepAgents 框架集成。当用户在 invoke() 请求中传入 knowledge_base_ids 时,这些工具自动注册到 Agent 的工具集中。

search_knowledge_base

Agent 主动搜索知识库中的相关信息,支持多知识库并行检索、可调节的检索权重。
query
string
必填
搜索查询(自然语言)
knowledge_base_id
string
指定知识库 ID。不指定则搜索所有已配置的知识库
top_k
number
默认值:"5"
返回数量
vector_weight
number
默认值:"0.6"
向量搜索权重(0-1)
keyword_weight
number
默认值:"0.4"
关键词搜索权重(0-1)
use_rerank
boolean
默认值:"true"
是否使用 RRF 重排序。关闭后直接返回向量搜索结果(更快)

Agent 调用示例

# 搜索所有已配置的知识库
search_knowledge_base("产品使用说明")

# 指定知识库
search_knowledge_base("XYZ-2000 产品规格", knowledge_base_id="kb_123")

# 提高关键词权重(适合精确术语搜索)
search_knowledge_base("getUserInfo 接口参数", keyword_weight=0.7, vector_weight=0.3)

# 快速模式,跳过 RRF 重排序
search_knowledge_base("快速查询", use_rerank=False)

parse_resource_file

解析用户在 Resource 区上传的文件,支持所有文档格式和图片(通过 Vision API)。
file_id
string
必填
Resource 文件 ID
parse_images
boolean
默认值:"true"
是否使用 Vision API 识别图片内容
max_length
number
默认值:"5000"
最大返回文本长度

Agent 调用示例

# 解析上传的 PDF 文档
parse_resource_file(file_id="res_abc123")

# 解析图片(使用 Vision API)
parse_resource_file(file_id="res_img456", parse_images=True)

# 限制返回长度
parse_resource_file(file_id="res_abc123", max_length=2000)