获取切片列表
更新时间:2025-03-10
接口描述
获取切片列表
权限说明
Authorization需要填写密钥。
接口定义
Path | /v2/knowledgeBase?Action=DescribeChunks |
---|---|
Method | POST |
Content-Type | application/json |
Authorization | 请求签名(Bearer <AppBuilder API Key>) |
请求结构
Plain Text
1POST /v2/knowledgeBase?Action=DescribeChunks HTTP/1.1
2HOST: qianfan.baidubce.com
3Authorization: Bearer <AppBuilder API Key>
4Content-Type: application/json
5
6{
7 "knowledgeBaseId": "knowledgeBaseID",
8 "documentId": "文档id",
9 "marker": "切片起始位置id",
10 "maxKeys": 10,
11 "type": "RAW" # 根据切片类型获取切片列表,
12 "keyword": "hi"
13}
请求头域
除公共头域外,无其它特殊头域。
请求参数
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
knowledgeBaseId | string | 是 | 知识库ID |
documentId | string | 是 | 文档ID |
marker | string | 否 | 用于分页的游标,与查询条件query绑定。 如果查询条件发生变化,之前的marker就会失效,无法继续翻页,需要重新获取新的marker。 |
maxKeys | int | 否 | 数据大小,默认10,最大值100 |
type | string | 否 | 根据类型获取切片列表。 可选值: RAW:原文切片 NEW:新增切片 COPY:复制切片 |
keyword | string | 否 | 根据关键字模糊匹配切片,最大长度2000字符 |
响应头域
除公共头域外,无其它特殊头域。
响应参数
字段 | 类型 | 必然存在 | 说明 |
---|---|---|---|
requestId | string | 是 | 请求ID |
data | []dict | 是 | 切片列表 |
data / id | string | 是 | 切片ID |
data / type | string | 是 | 切片类型。 枚举值: RAW:原文切片 NEW:新增切片 COPY:复制切片 |
data / knowledgeBaseId | string | 是 | 切片所属知识库ID |
data / documentId | string | 是 | 切片所属文档ID |
data / content | string | 是 | 切片内容(需要截断) |
data / wordCount | int | 是 | 切片内字符数量 |
data / tokenCount | int | 是 | 切片内token数量 |
data / enabled | bool | 是 | 是否生效 |
data / status | string | 是 | 切片状态。 枚举值: Indexed:已完成 Indexing:处理中 |
data / statusMessage | string | 是 | 切片状态详细描述 |
data / createTime | time.Time | 是 | 创建时间 |
data / updateTime | time.TIme | 是 | 更新时间 |
marker | string | 是 | 起始位置 |
isTruncated | bool | 是 | true表示后面还有数据,false表示已经是最后一页 |
nextMarker | string | 是 | nextMarker下次查询的起始位置 |
maxKeys | int | 是 | 本次查询包含的最大结果集数量 |
请求curl 示例
Plain Text
1curl --location 'https://qianfan.baidubce.com/v2/knowledgeBase?Action=DescribeChunks' \
2--header 'Authorization: Bearer string' \
3--header 'Content-Type: application/json' \
4--data '{
5 "knowledgeBaseId":"c45adb4c-b2c9-4c88-aaac-56756b215e06",
6 "documentId": "c2f128b4-e9ed-46df-a1b7-034e77ce8c89",
7 "marker": "cfdc5bba-f047-4e81-a5fa-06d40c0fd846",
8 "maxKeys": 10,
9 "type": "RAW",
10 "keyword":"青海市水资源公报"
11}'
正确响应示例
Plain Text
1HTTP/1.1 200 OK
2{
3 "requestId": "733690dd-1168-4458-82a7-b47169be37c4",
4 "data": [
5 {
6 "id": "96f692b9-fc2d-4da1-943f-9922d46e5576",
7 "type": "RAW",
8 "knowledgeBaseId": "5e817931-4bc2-4cfe-b40c-0fe9371234b8",
9 "documentId": "c2f188b4-e9ed-46df-a1b7-034e77ce8c89",
10 "content": "《青海省水资源公报》依据《水资源公报编制规程》(GB/T23598-2009)进行编制,内容包括:综述、水资源量、蓄水动态、水资源利用、重要水事等。在编制过程中,得到了省内气象、统计、城乡建设、生态环",
11 "wordCount": 166,
12 "tokenCount": 127,
13 "enabled": true,
14 "status": "indexed",
15 "statusMessage": "None",
16 "createTime": 1721307226,
17 "updateTime": 1721307227
18 }
19 ],
20 "marker": "cfdc5bba-f047-4e81-a5fa-06d40c0fd846",
21 "isTruncated": false,
22 "nextMarker": "d3f97da1-e9a1-4ae1-91d9-e55e87db382a",
23 "maxKeys": 2
24}
错误响应示例
Plain Text
1HTTP/1.1 401
2{
3 "requestId": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
4 "code": "PermissionDeniedError",
5 "message": "没有权限"
6}