DocumentUpload - 上传文档
更新时间:2025-12-25
API访问域名
| 请求方式 | POST |
|---|---|
| base url | https://keyue.cloud.baidu.com |
| 后缀接口 | /open/v1/api/v2/task/create/llm_document_import |
| Authentication | token为API Key |
说明
请求参数
Header参数
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| Content-Type | string | 是 | 内容类型 | 固定值:application/json |
| token | string | 是 | API KEY | 机器人API KEY。 详细获取方式参考:准备工作 |
| uid | string | 是 | 用户ID | 详细获取方式参考:准备工作 |
| username | string | 是 | 用户名 | 详细获取方式参考:准备工作 |
Parameter参数
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| dirId | string | 是 | 目录Id | 上传文档到对应目录下 |
Body参数
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| file | file | 是 | 文档 | |
| taskExtend | string | 是 | 文档训练参数 | 为空代表"{}":自动分段与数据清洗。有值代表: 1、分段标识符split_by:换行切分punc、标点切分wrap 2、分段最大长度chunk_size(200-800) 3、分段重叠比overlap_proportion(0-20) 4、文本预处理(删除连续空格、换行、制表符):pre_handle_text 5、文本预处理(删除目录、页眉、页脚):pre_handle_directory |
响应参数
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| time | integer | 是 | 时间 | 1717469424958 |
| data | object | 是 | 数据 | 数据对象 ,详见data子数据 |
| code | integer | 是 | 状态码 | 200 |
| msg | string | 是 | 状态信息 | OK |
data子数据
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 文档id | |
| agentId | string | 是 | ||
| agentName | string | 是 | ||
| agentType | integer | 是 | ||
| userId | string | 是 | uid | |
| userName | string | 是 | username | |
| created | string | 是 | ||
| updated | string | 是 | ||
| module | string | 是 | ||
| taskType | string | 是 | ||
| taskStatus | integer | 是 | ||
| taskResult | null | 否 | ||
| errorMsg | null | 否 | ||
| filePath | string | 是 | 文件路径 | Ym9zXzVhMzRlZDdhLTk0MjEtNGEzNy05MzQ1LWMzNWZmODhiZjBjNg== |
| fileUrl | null | 否 | 文件URL | null |
| taskUrl | string | 是 | 任务URL | /api/v2/llm/document/import |
| deleted | integer | 是 | 是否删除 | 0 |
| reportFilePath | null | 否 | 报告文件路径 | null |
| reportFileUrl | null | 否 | 报告文件URL | null |
| taskExtend | string | 是 | 任务扩展 | {"split_by":"wrap","chunk_size":700,"overlap_proportion":10,"pre_handle_text":true,"pre_handle_directory":false} |
| commonExtend | null | 否 | 通用扩展 | null |
| tenantId | string | 是 | 租户ID | 3156952326602753 |
| appName | null | 否 | 应用名称 | null |
| platform | string | 是 | 平台 | NGD |
| requestSource | string | 是 | 请求来源 | UNIT |
请求示例
Bash
1curl --location --request POST 'https://keyue.cloud.baidu.com/open/v1/api/v2/task/create/llm_document_import?dirId=0' \
2--header 'token: xxxx' \
3--header 'Content-Type: application/json' \
4--header 'uid: cf7d9692703d45d1b5517a30ab3efa53' \
5--header 'username: pnstest5' \
6--form 'file=@"/Users/jiangkang/Desktop/jiangkang/照片&证件材料/话费发票/2024年3月话费.pdf"' \
7--form 'taskExtend="{\"split_by\":\"wrap\",\"chunk_size\":700,\"overlap_proportion\":10,\"pre_handle_text\":true,\"pre_handle_directory\":false}"'
响应示例
1{
2 "time": 1717469424958,
3 "data": {
4 "id": "64cd68de-693b-40e1-b823-ea9df9fc4c42",
5 "agentId": "dc4f2aff-d70c-444e-9b2d-4ff1f569c45b",
6 "agentName": "啦啦啦啦",
7 "agentType": 1,
8 "userId": "cf7d9692703d45d1b5517a30ab3efa53",
9 "userName": "pnstest5",
10 "created": "2024-06-04 10:50:24",
11 "updated": "2024-06-04 10:50:24",
12 "module": "llm",
13 "taskType": "import",
14 "taskStatus": 0,
15 "taskResult": null,
16 "errorMsg": null,
17 "filePath": "Ym9zXzVhMzRlZDdhLTk0MjEtNGEzNy05MzQ1LWMzNWZmODhiZjBjNg==",
18 "fileUrl": null,
19 "taskUrl": "/api/v2/llm/document/import",
20 "deleted": 0,
21 "reportFilePath": null,
22 "reportFileUrl": null,
23 "taskExtend": "{\"split_by\":\"wrap\",\"chunk_size\":700,\"overlap_proportion\":10,\"pre_handle_text\":true,\"pre_handle_directory\":false}",
24 "commonExtend": null,
25 "tenantId": "3156952326602753",
26 "appName": null,
27 "platform": "NGD",
28 "requestSource": "UNIT"
29 },
30 "code": 200,
31 "msg": "OK"
32}
1{
2 "msg":"服务器处理该请求失败,请检查请求是否合法",
3 "requestId":"9b49672d990d45b0be781582f5e34511",
4 "code":4002012
5}
