查询知识库文档列表
更新时间:2025-02-18
接口描述
该接口用于查询指定知识库中的文档列表。
权限说明
Authorization需要填写密钥。
接口定义
Path | /v2/knowledgeBase?Action=DescribeDocuments |
---|---|
Method | POST |
Content-Type | application/json |
Authorization | 请求签名(Bearer <AppBuilder API Key>) |
请求结构
POST /v2/knowledgeBase?Action=DescribeDocuments HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <AppBuilder API Key>
{
"knowledgeBaseId": "知识库id",
"marker": "知识库文档id",
"maxKeys": 10
}
请求头域
除公共头域外,无其它特殊头域。
请求参数
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
knowledgeBaseId | string | 是 | 知识库ID |
marker | string | 否 | 起始位置,知识库文档id |
maxKeys | integer | 否 | 数据大小,默认10,最大值100 |
响应头域
除公共头域外,无其它特殊头域。
响应参数
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
requestId | string | 是 | requestId |
marker | string | 是 | 起始位置 |
isTruncated | bool | 是 | true表示后面还有数据,false表示已经是最后一页 |
nextMarker | string | 是 | nextMarker下次查询的起始位置 |
maxKeys | int | 是 | 本次查询包含的最大结果集数量 |
data | list[object] | 是 | Document 对象列表 |
Document对象
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
id | string | 是 | id |
name | string | 是 | 上传时的文档名 |
createdAt | string | 是 | 创建时间, UTC时间格式 |
displayStatus | string | 是 | 文档上传后的状态。 枚举值: queuing:排队中 notConfigured:数据待配置 paused:处理暂停 parsing:解析中 indexing:处理中 parseError:解析失败 error:处理失败 available:可用 retrainingSegmentUnusable:重建切片中,切片不可用 retrainErrSegmentUsable:重建切片错误,旧切片可用 |
wordCount | integer | 是 | 字数 |
enabled | bool | 是 | 是否可用 |
meta | object | 是 | source、fileId |
extension | string | 否 | 文件扩展名 |
size | int | 否 | 文档字符数 |
url | string | 否 | 文档下载地址 |
文档meta 对象
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
source | string | 是 | 来源。 枚举值: upload_file:文本文档数据 datatable:表格型知识数据 url:网页数据 |
fileId | string | 否 | 上传文档id。当source值为url时,该值为null |
请求curl 示例
curl --location --request POST 'https://qianfan.baidubce.com/v2/knowledgeBase?Action=DescribeDocuments' \
--header 'Authorization: Bearer <AppBuilder API Key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"knowledgeBaseId": "ce27cf70-9287-4b60-82c0-7beba1537ba0",
"marker": "marker_id",
"maxKeys": 10
}'
正确响应示例
HTTP/1.1 200 OK
{
"requestId": "b5b2a4e8-9750-4630-b104-afbda26c6b4e",
"marker": "",
"isTruncated": false,
"nextMarker": "49256eb7-9014-443b-a1d5-107a9f035626",
"maxKeys": 1,
"data": [
{
"id": "49256eb7-9014-443b-a1d5-107a9f035626",
"name": "2019年金融行业开源治理白皮书.pdf",
"createdAt": "2025-02-05T08:12:15Z",
"displayStatus": "available",
"wordCount": 21196,
"enabled": true,
"meta": {
"source": "upload_file",
"fileId": "93f1f9f1-0440-449e-9846-f6fee92ca692"
}
}
]
}
错误响应示例
{
"requestId": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
"code": "PermissionDeniedError",
"message": "没有权限"
}