Files
aue/向量化api文档.md
2026-06-14 14:56:54 +08:00

113 lines
3.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
文件向量化接口文档
1. 单个文件智能向量化
接口信息
接口名称: 智能文件向量化
请求方式: POST
接口路径: /collection/vectorize/smart
完整URL: http://localhost:8080/api/collection/vectorize/smart?fileId=123
功能描述
自动判断文件所属部门的向量库并执行向量化处理无需手动指定向量库名称。系统会根据文件的部门ID自动确定目标向量库。
请求参数
![image-20260608163723909](../AppData/Roaming/Typora/typora-user-images/image-20260608163723909.png)
请求示例
curl -X POST "http://localhost:8080/api/collection/vectorize/smart?fileId=123" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
响应参数
![image-20260608163742632](../AppData/Roaming/Typora/typora-user-images/image-20260608163742632.png)
响应示例
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "向量化任务已提交,正在后台处理中",
"fileId": 123,
"fileName": "example.pdf",
"collection": "dept_1_kb",
"status": "VECTORIZING"
}
}
2. 批量文件智能向量化
接口信息
接口名称: 批量智能文件向量化
请求方式: POST
接口路径: /collection/vectorize/batch/smart
完整URL: http://localhost:8080/api/collection/vectorize/batch/smart?fileIds=123,124,125
功能描述
批量处理多个文件的向量化任务,系统会自动为每个文件判断所属部门的向量库并分别提交向量化任务。
请求参数
![image-20260608163811717](../AppData/Roaming/Typora/typora-user-images/image-20260608163811717.png)
请求示例
curl -X POST "http://localhost:8080/api/collection/vectorize/batch/smart?fileIds=123,124,125" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
![image-20260608163822658](../AppData/Roaming/Typora/typora-user-images/image-20260608163822658.png)
![image-20260608164018709](../AppData/Roaming/Typora/typora-user-images/image-20260608164018709.png)
响应示例
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "批量向量化任务已提交: 提交 3 个, 无效 0 个",
"batchId": "BATCH_1717890123456",
"submittedFiles": [
{
"fileId": 123,
"fileName": "document1.pdf",
"collection": "dept_1_kb",
"status": "SUBMITTED"
},
{
"fileId": 124,
"fileName": "document2.pdf",
"collection": "dept_2_kb",
"status": "SUBMITTED"
},
{
"fileId": 125,
"fileName": "document3.pdf",
"collection": "public_kb",
"status": "SUBMITTED"
}
],
"failedFiles": [],
"total": 3,
"submittedCount": 3,
"failedCount": 0
}
}
注意事项
两个接口都需要用户登录认证需在请求头中携带有效的JWT Token
向量化任务是异步执行的,接口立即返回任务提交结果
文件必须已经上传到服务器且路径有效
系统会根据文件的部门ID自动选择合适的向量库
有部门ID的文件会分配到对应的部门向量库
无部门ID但公开的文件会分配到公共向量库
其他情况会分配到私有向量库
批量处理时,单个文件失败不会影响其他文件的处理