知识库
批量
请求字段、响应对象和当前限制。
路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。
创建文件批次
POST /knowledge/v1/vector_stores/{vector_store_id}/file_batches
批量添加已有 File 并异步入库。file_ids 与 files 必须且只能提供一个;files 支持逐文件设置。已有附件直接复用。使用返回的批次 id 查询进度。
参数
| 名称 | 位置与类型 | 说明 |
|---|---|---|
| vector_store_id | path: string | 必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1 |
请求体
file_ids 与 files 必须且只能提供一个。已有文件直接复用,不修改属性或分段策略。
| 字段 | 类型 | 说明 |
|---|---|---|
| (1).file_ids | string[] | 必填; 使用共同属性和分段设置的已有 File ID 列表。file_ids 与 files 二选一。; 最少条数: 1; 最多条数: 500 |
| (1).attributes | object / null | 可选; 用于每个新附件的搜索筛选属性;省略或 null 表示不设置。 |
| (1).chunking_strategy | object / object | 可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"} |
| (1).chunking_strategy (1).type | "auto" | 必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。 |
| (1).chunking_strategy (2).type | "static" | 必填; static 表示使用显式分段大小与重叠设置。 |
| (1).chunking_strategy (2).static | object | 必填; 以估算 token 数表示的分段大小与重叠限制。 |
| (1).chunking_strategy (2).static.max_chunk_size_tokens | integer | 必填; 每段的估算 token 数。; 最小: 100; 最大: 4096 |
| (1).chunking_strategy (2).static.chunk_overlap_tokens | integer | 必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048 |
| (2).files | object[] | 必填; 分别指定属性和分段设置的附件列表;忽略顶层 attributes 与 chunking_strategy。; 最少条数: 1; 最多条数: 500 |
| (2).files[].file_id | string | 必填; 上传文件返回的已有源 File ID;文件必须对调用方可见。; 最短字符数: 1 |
| (2).files[].attributes | object | 可选; 用于搜索筛选的文件属性。最多 16 个键,键最多 64 字符,字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string / number / boolean |
| (2).files[].chunking_strategy | object / object | 可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"} |
| (2).files[].chunking_strategy (1).type | "auto" | 必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。 |
| (2).files[].chunking_strategy (2).type | "static" | 必填; static 表示使用显式分段大小与重叠设置。 |
| (2).files[].chunking_strategy (2).static | object | 必填; 以估算 token 数表示的分段大小与重叠限制。 |
| (2).files[].chunking_strategy (2).static.max_chunk_size_tokens | integer | 必填; 每段的估算 token 数。; 最小: 100; 最大: 4096 |
| (2).files[].chunking_strategy (2).static.chunk_overlap_tokens | integer | 必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048 |
| (2).attributes | JSON | 可选; 不生效: 使用 files 时不生效。 |
| (2).chunking_strategy | JSON | 可选; 不生效: 使用 files 时不生效。 |
请求示例
curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches" \
-H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"file_ids\":[\"${FILE_ID}\"]}"响应
HTTP 200
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 必有; 资源 ID。; 最短字符数: 1 |
| object | "vector_store.files_batch" | 必有; 对象标记;vector_store.files_batch 表示批量附件。 |
| vector_store_id | string | 必有; 资源 ID。; 最短字符数: 1 |
| status | "in_progress" / "completed" / "cancelled" / "failed" | 必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。 |
| file_counts | object | 必有; 仍属于该库或批次的附件数量,按入库状态分组。 |
| file_counts.in_progress | integer | 必有; 等待或正在入库的文件数。; 最小: 0 |
| file_counts.completed | integer | 必有; 已完成入库的文件数。; 最小: 0 |
| file_counts.failed | integer | 必有; 入库失败的文件数。; 最小: 0 |
| file_counts.cancelled | integer | 必有; 因批次取消而停止入库的文件数。; 最小: 0 |
| file_counts.total | integer | 必有; 全部入库状态的附件总数。; 最小: 0 |
| created_at | integer | 必有; Unix 时间戳,单位秒。 |
读取文件批次
GET /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}
读取此知识库中创建的批次,包括当前状态和文件计数。使用创建批次返回的 id 监测入库结果。
参数
| 名称 | 位置与类型 | 说明 |
|---|---|---|
| vector_store_id | path: string | 必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1 |
| batch_id | path: string | 必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1 |
请求示例
curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}" \
-H "Authorization: Bearer $PRAXIS_API_KEY"响应
HTTP 200
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 必有; 资源 ID。; 最短字符数: 1 |
| object | "vector_store.files_batch" | 必有; 对象标记;vector_store.files_batch 表示批量附件。 |
| vector_store_id | string | 必有; 资源 ID。; 最短字符数: 1 |
| status | "in_progress" / "completed" / "cancelled" / "failed" | 必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。 |
| file_counts | object | 必有; 仍属于该库或批次的附件数量,按入库状态分组。 |
| file_counts.in_progress | integer | 必有; 等待或正在入库的文件数。; 最小: 0 |
| file_counts.completed | integer | 必有; 已完成入库的文件数。; 最小: 0 |
| file_counts.failed | integer | 必有; 入库失败的文件数。; 最小: 0 |
| file_counts.cancelled | integer | 必有; 因批次取消而停止入库的文件数。; 最小: 0 |
| file_counts.total | integer | 必有; 全部入库状态的附件总数。; 最小: 0 |
| created_at | integer | 必有; Unix 时间戳,单位秒。 |
取消文件批次
POST /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel
只取消处理中的批次和文件。已完成、失败或已取消的批次原样返回(200,幂等),计数不变。
参数
| 名称 | 位置与类型 | 说明 |
|---|---|---|
| vector_store_id | path: string | 必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1 |
| batch_id | path: string | 必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1 |
请求示例
curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/cancel" \
-H "Authorization: Bearer $PRAXIS_API_KEY"响应
HTTP 200
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 必有; 资源 ID。; 最短字符数: 1 |
| object | "vector_store.files_batch" | 必有; 对象标记;vector_store.files_batch 表示批量附件。 |
| vector_store_id | string | 必有; 资源 ID。; 最短字符数: 1 |
| status | "in_progress" / "completed" / "cancelled" / "failed" | 必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。 |
| file_counts | object | 必有; 仍属于该库或批次的附件数量,按入库状态分组。 |
| file_counts.in_progress | integer | 必有; 等待或正在入库的文件数。; 最小: 0 |
| file_counts.completed | integer | 必有; 已完成入库的文件数。; 最小: 0 |
| file_counts.failed | integer | 必有; 入库失败的文件数。; 最小: 0 |
| file_counts.cancelled | integer | 必有; 因批次取消而停止入库的文件数。; 最小: 0 |
| file_counts.total | integer | 必有; 全部入库状态的附件总数。; 最小: 0 |
| created_at | integer | 必有; Unix 时间戳,单位秒。 |
列出批次文件
GET /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files
列出指定批次仍在库中的附件,默认最新附件在前。使用批次创建返回的 id;?filter=failed 查看失败文件,last_id 可作为下一页 after。
参数
| 名称 | 位置与类型 | 说明 |
|---|---|---|
| vector_store_id | path: string | 必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1 |
| batch_id | path: string | 必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1 |
| after | query: string | 上一页的 ID 游标。 最短字符数: 1 |
| before | query: string | 返回此 ID 之前的条目。 最短字符数: 1 |
| limit | query: integer | 每页条数。 最小: 1; 最大: 100; 默认: 20 |
| order | query: "asc" / "desc" | 知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc" |
| filter | query: "in_progress" / "completed" / "failed" / "cancelled" | in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。省略时包含全部状态。 |
请求示例
curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/files" \
-H "Authorization: Bearer $PRAXIS_API_KEY"响应
HTTP 200
| 字段 | 类型 | 说明 |
|---|---|---|
| object | "list" | 必有; 对象标记;list 表示游标分页集合。 |
| data | object[] | 必有; 按请求顺序返回的当前页条目。 |
| data[].id | string | 必有; 与源文件相同的 ID。; 最短字符数: 1 |
| data[].object | "vector_store.file" | 必有; 对象标记;vector_store.file 表示知识库中的附件。 |
| data[].vector_store_id | string | 必有; 资源 ID。; 最短字符数: 1 |
| data[].status | "in_progress" / "completed" / "cancelled" / "failed" | 必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。 |
| data[].last_error | object / null | 必有; 入库失败详情;未失败、成功完成或重新入库时为 null。 |
| data[].last_error (1).code | "server_error" / "unsupported_file" / "invalid_file" | 必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。 |
| data[].last_error (1).message | string | 必有; 与 code 对应的入库失败说明。 |
| data[].usage_bytes | integer | 必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0 |
| data[].created_at | integer | 必有; Unix 时间戳,单位秒。 |
| data[].chunking_strategy | object / object | 必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。 |
| data[].chunking_strategy (1).type | "static" | 必有; static 表示使用显式分段大小与重叠设置。 |
| data[].chunking_strategy (1).static | object | 必有; 以估算 token 数表示的分段大小与重叠限制。 |
| data[].chunking_strategy (1).static.max_chunk_size_tokens | integer | 必有; 每段的估算 token 数。; 最小: 100; 最大: 4096 |
| data[].chunking_strategy (1).static.chunk_overlap_tokens | integer | 必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048 |
| data[].chunking_strategy (2).type | "other" | 必有 |
| data[].attributes | object / null | 必有; 用于搜索筛选的文件属性;null 表示未设置。 |
| data[].praxis | object | 可选; 原生入库进度与源文件统计。 |
| data[].praxis.stage | "queued" / "parse" / "chunk" / "embed" / "index" / null | 必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。 |
| data[].praxis.deadline_at | integer / null | 必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。 |
| data[].praxis.filename | string | 必有; File 服务返回的源文件名。 |
| data[].praxis.bytes | integer | 必有; 源文件字节数。; 最小: 0 |
| data[].praxis.pages | integer / null | 必有; 成功入库后的解析页数;成功结果保存前为 null。 |
| data[].praxis.chunk_count | integer | 必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0 |
| first_id | string / null | 必有; 本页首项的 ID;空页为 null。 |
| last_id | string / null | 必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。 |
| has_more | boolean | 必有; 当前游标范围内,本页之后是否还有条目。 |