| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- from fastapi import APIRouter
- from app.schemas.training import TrainingConfig, TrainingJobResponse, TrainingProgress
- router = APIRouter()
- @router.post("/jobs", response_model=TrainingJobResponse)
- async def create_training_job(config: TrainingConfig):
- """创建并加入训练任务。"""
- return TrainingJobResponse(
- id="placeholder",
- model_id=config.model_id,
- model_type=config.model_type.value,
- peft_method=config.peft_method.value,
- status="pending",
- created_at="",
- )
- @router.get("/jobs", response_model=list[TrainingJobResponse])
- async def list_training_jobs():
- """列出所有训练任务。"""
- return []
- @router.get("/jobs/{job_id}", response_model=TrainingJobResponse)
- async def get_training_job(job_id: str):
- """获取指定任务详情。"""
- return TrainingJobResponse(
- id=job_id,
- model_id="",
- model_type="text",
- peft_method="lora",
- status="pending",
- created_at="",
- )
- @router.post("/jobs/{job_id}/cancel")
- async def cancel_training_job(job_id: str):
- """取消运行中的训练任务。"""
- return {"status": "cancelled"}
- @router.get("/jobs/{job_id}/logs")
- async def stream_training_logs(job_id: str):
- """通过 SSE 流式推送训练日志。"""
- return {"logs": []}
|