feat(plan): 生成 label_backend 完整实施规划文档
Phase 0:research.md(10项技术决策,无需澄清项) Phase 1:data-model.md(11张表+Redis结构),contracts/(8个模块API契约),quickstart.md(Docker Compose启动+流水线验证) plan.md:宪章11条全部通过,项目结构确认
This commit is contained in:
113
specs/001-label-backend-spec/contracts/export.md
Normal file
113
specs/001-label-backend-spec/contracts/export.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# API 契约:训练数据导出与微调
|
||||
|
||||
*所有接口需要 ADMIN 权限*
|
||||
|
||||
---
|
||||
|
||||
## GET /api/training/samples
|
||||
|
||||
**描述**: 分页查询已审批、可导出的训练样本
|
||||
|
||||
**查询参数**: `page`、`pageSize`、`sampleType`(TEXT / IMAGE / VIDEO_FRAME,可选)、`exported`(true/false,可选)
|
||||
|
||||
**响应** `200`:
|
||||
```json
|
||||
{
|
||||
"code": "SUCCESS",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"id": 1001,
|
||||
"sampleType": "TEXT",
|
||||
"status": "APPROVED",
|
||||
"exportBatchId": null,
|
||||
"sourceId": 50,
|
||||
"createdAt": "2026-04-09T12:00:00"
|
||||
}
|
||||
],
|
||||
"total": 500,
|
||||
"page": 1,
|
||||
"pageSize": 20
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## POST /api/export/batch
|
||||
|
||||
**描述**: 创建导出批次,合并选定样本为 JSONL 并上传 RustFS
|
||||
|
||||
**请求体**:
|
||||
```json
|
||||
{
|
||||
"sampleIds": [1001, 1002, 1003]
|
||||
}
|
||||
```
|
||||
|
||||
**成功响应** `201`:
|
||||
```json
|
||||
{
|
||||
"code": "SUCCESS",
|
||||
"data": {
|
||||
"id": 10,
|
||||
"batchUuid": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"sampleCount": 3,
|
||||
"datasetFilePath": "export/550e8400.jsonl",
|
||||
"finetuneStatus": "NOT_STARTED"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**失败**:
|
||||
- `400` `INVALID_SAMPLES`: 部分样本不处于 APPROVED 状态
|
||||
- `400` `EMPTY_SAMPLES`: sampleIds 为空
|
||||
|
||||
---
|
||||
|
||||
## POST /api/export/{batchId}/finetune
|
||||
|
||||
**描述**: 向 GLM AI 服务提交微调任务
|
||||
|
||||
**响应** `200`:
|
||||
```json
|
||||
{
|
||||
"code": "SUCCESS",
|
||||
"data": {
|
||||
"glmJobId": "glm-finetune-abc123",
|
||||
"finetuneStatus": "RUNNING"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**失败**: `409` `FINETUNE_ALREADY_STARTED`: 微调任务已提交
|
||||
|
||||
---
|
||||
|
||||
## GET /api/export/{batchId}/status
|
||||
|
||||
**描述**: 查询微调任务状态(向 AI 服务实时查询)
|
||||
|
||||
**响应** `200`:
|
||||
```json
|
||||
{
|
||||
"code": "SUCCESS",
|
||||
"data": {
|
||||
"batchId": 10,
|
||||
"glmJobId": "glm-finetune-abc123",
|
||||
"finetuneStatus": "RUNNING",
|
||||
"progress": 45,
|
||||
"errorMessage": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GET /api/export/list
|
||||
|
||||
**描述**: 分页查询所有导出批次
|
||||
|
||||
**查询参数**: `page`、`pageSize`
|
||||
|
||||
**响应** `200`: 批次列表(含 finetuneStatus、sampleCount、createdAt 等字段)
|
||||
Reference in New Issue
Block a user