113 lines
3.4 KiB
Markdown
113 lines
3.4 KiB
Markdown
文件向量化接口文档
|
||
1. 单个文件智能向量化
|
||
接口信息
|
||
接口名称: 智能文件向量化
|
||
请求方式: POST
|
||
接口路径: /collection/vectorize/smart
|
||
完整URL: http://localhost:8080/api/collection/vectorize/smart?fileId=123
|
||
功能描述
|
||
自动判断文件所属部门的向量库并执行向量化处理,无需手动指定向量库名称。系统会根据文件的部门ID自动确定目标向量库。
|
||
请求参数
|
||

|
||
请求示例
|
||
|
||
curl -X POST "http://localhost:8080/api/collection/vectorize/smart?fileId=123" \
|
||
-H "Authorization: Bearer YOUR_JWT_TOKEN"
|
||
|
||
响应参数
|
||
|
||

|
||
|
||
响应示例
|
||
|
||
{
|
||
"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
|
||
功能描述
|
||
批量处理多个文件的向量化任务,系统会自动为每个文件判断所属部门的向量库并分别提交向量化任务。
|
||
请求参数
|
||
|
||

|
||
|
||
请求示例
|
||
|
||
curl -X POST "http://localhost:8080/api/collection/vectorize/batch/smart?fileIds=123,124,125" \
|
||
-H "Authorization: Bearer YOUR_JWT_TOKEN"
|
||
|
||

|
||
|
||

|
||
|
||
响应示例
|
||
|
||
{
|
||
"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但公开的文件会分配到公共向量库
|
||
其他情况会分配到私有向量库
|
||
批量处理时,单个文件失败不会影响其他文件的处理
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|