查询知识库文档列表
更新时间:2025-04-29
接口描述
该接口用于查询指定知识库中的文档列表。
权限说明
调用本API,需使用API Key鉴权方式。Authorization的值为Bearer <AppBuilder API Key>。获取API Key流程,请查看授权
接口定义
Path | /v2/knowledgeBase?Action=DescribeDocuments |
---|---|
Method | POST |
Content-Type | application/json |
Authorization | 请求签名(Bearer <AppBuilder API Key>) |
请求结构
Plain Text
1POST /v2/knowledgeBase?Action=DescribeDocuments HTTP/1.1
2HOST: qianfan.baidubce.com
3Authorization: Bearer <AppBuilder API Key>
4{
5 "knowledgeBaseId": "知识库id",
6 "marker": "知识库文档id",
7 "maxKeys": 10,
8 "keyword": "医疗卫生常识"
9}
请求头域
除公共头域外,无其它特殊头域。
请求参数
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
knowledgeBaseId | string | 是 | 知识库ID |
marker | string | 否 | 起始位置,知识库文档id |
maxKeys | integer | 否 | 数据大小,默认10,最大值100 |
keyword | string | 否 | 搜索关键字 |
响应头域
除公共头域外,无其它特殊头域。
响应参数
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
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 | 是 | meta对象 |
文档meta 对象
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
source | string | 是 | 来源。 枚举值: upload_file:文本文档数据 datatable:表格型知识数据 url:网页数据 |
fileId | string | 否 | 上传文档id。当source值为url时,该值为null |
url | string | 否 | 原文件下载链接 |
mime_type | string | 否 | 文件类型,目前支持doc/txt/docx/pdf/ppt/pptx/xlsx/xls/csv/json这几种文件类型。 如果是通过url方式导入的文档,该值为url |
file_size | int | 否 | 文件大小,单位bytes |
tags | list[Tag] | 否 | 文档标签 |
Tag对象
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
key | string | 是 | 标签 key |
values | list[string] | 是 | 标签value |
请求curl 示例
Plain Text
1curl --location --request POST 'https://qianfan.baidubce.com/v2/knowledgeBase?Action=DescribeDocuments' \
2--header 'Authorization: Bearer <AppBuilder API Key>' \
3--header 'Content-Type: application/json' \
4--data-raw '{
5 "knowledgeBaseId": "ce27cf70-9287-4b60-82c0-7beba1537ba0",
6 "marker": "marker_id",
7 "maxKeys": 10,
8 "keyword": "医疗卫生常识"
9}'
正确响应示例
Plain Text
1HTTP/1.1 200 OK
2{
3 "requestId": "c2db9c49-5a94-429a-9814-b26272075ae9",
4 "marker": "",
5 "isTruncated": false,
6 "nextMarker": "3bec3435-8972-4cab-a4c6-1527da3713ed",
7 "maxKeys": 1,
8 "data": [
9 {
10 "id": "3bec3435-8972-4cab-a4c6-1527da3713ed",
11 "name": "医疗卫生常识.doc",
12 "createdAt": "2024-06-03T02:39:04Z",
13 "displayStatus": "available",
14 "wordCount": 80618,
15 "enabled": true,
16 "meta": {
17 "source": "upload_file",
18 "fileId": "86834d5d-2cea-4a42-98cf-a3ed89f3697f",
19 "mimeType": "doc",
20 "fileSize": 760872,
21 "url": "https://copilot-engine-bos.bj.bcebos.com/upload_files/549df68c-ff81-4768-a00f-1b34c713a59f/9523c796-191c-4add-8e.doc?authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2025-04-29T15%3A10%3A17Z15fa494755a3152fa53c0f3895b4565a20fef8a718876bd968517054752ae6",
22 "tags": [
23 {
24 "key": "知识",
25 "values": [
26 "医疗知识"
27 ]
28 }
29 ]
30 }
31 }
32 ]
33}
错误响应示例
Plain Text
1{
2 "requestId": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
3 "code": "PermissionDeniedError",
4 "message": "没有权限"
5}