新增切片
更新时间:2025-02-18
接口描述
为当前知识库中指定文档新增切片
权限说明
Authorization需要填写密钥。
接口定义
| Path | /v2/knowledgeBase?Action=CreateChunk | 
|---|---|
| Method | POST | 
| Content-Type | application/json | 
| Authorization | 请求签名(Bearer <AppBuilder API Key>) | 
请求结构
                Plain Text
                
            
            1POST /v2/knowledgeBase?Action=CreateChunk HTTP/1.1
2HOST: qianfan.baidubce.com
3Authorization: Bearer <AppBuilder API Key>
4Content-Type: application/json
5
6{
7    "knowledgeBaseId":"knowledgeBaseId",
8    "documentId": "documentID",
9    "content": "content"
10}
            请求头域
除公共头域外,无其它特殊头域。
请求参数
| 字段 | 类型 | 是否必须 | 说明 | 
|---|---|---|---|
| knowledgeBaseId | string | 是 | 知识库ID | 
| documentId | string | 是 | 文档ID | 
| content | string | 是 | 切片内容(暂不支持表格型知识数据) | 
响应头域
除公共头域外,无其它特殊头域。
响应参数
| 字段 | 类型 | 必然存在 | 说明 | 
|---|---|---|---|
| requestId | string | 是 | 请求ID | 
| id | string | 是 | 切片id | 
请求curl 示例
                Plain Text
                
            
            1curl --location 'https://qianfan.baidubce.com/v2/knowledgeBase?Action=CreateChunk' \
2--header 'Authorization: Bearer <AppBuilder API Key>' \
3--header 'Content-Type: application/json' \
4--data '{
5    "documentId": "c2f188b4-e9ed-46df-a1b7-034e77ce8c89",
6    "content": "你好"
7}'
            正确响应示例
                Plain Text
                
            
            1HTTP/1.1 200 OK
2{
3    "requestId": "f5fb7546-33d5-47ae-97e4-7b8ce9e02d55",
4    "id": "32d372f7-f112-49e1-a9bc-2001ea15e1a4"
5}
            错误响应示例
                Plain Text
                
            
            1HTTP/1.1 401
2{
3  "requestId": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
4  "code": "PermissionDeniedError",
5  "message": "没有权限"
6}
            