2026-04-10 16:27:51 +08:00
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
|
|
|
|
|
|
from app.clients.llm.base import LLMClient
|
|
|
|
|
from app.core.dependencies import get_llm_client
|
|
|
|
|
from app.models.finetune_models import (
|
|
|
|
|
FinetuneStartRequest,
|
|
|
|
|
FinetuneStartResponse,
|
|
|
|
|
FinetuneStatusResponse,
|
|
|
|
|
)
|
|
|
|
|
from app.services import finetune_service
|
feat: Phase 1+2 — project setup and core infrastructure
- requirements.txt, config.yaml, .env, Dockerfile, docker-compose.yml
- app/core: config (YAML+env override), logging (JSON structured),
exceptions (typed hierarchy), json_utils (Markdown fence stripping)
- app/clients: LLMClient ABC + ZhipuAIClient (run_in_executor),
StorageClient ABC + RustFSClient (boto3 head_object for size check)
- app/main.py: FastAPI app with health endpoint and router registration
- app/core/dependencies.py: lru_cache singleton factories
- tests/conftest.py: mock_llm, mock_storage, test_app, client fixtures
- pytest.ini: asyncio_mode=auto
- 11 unit tests passing
2026-04-10 15:22:45 +08:00
|
|
|
|
|
|
|
|
router = APIRouter(tags=["Finetune"])
|
2026-04-10 16:27:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/finetune/start", response_model=FinetuneStartResponse)
|
|
|
|
|
async def start_finetune(
|
|
|
|
|
req: FinetuneStartRequest,
|
|
|
|
|
llm: LLMClient = Depends(get_llm_client),
|
|
|
|
|
) -> FinetuneStartResponse:
|
|
|
|
|
return await finetune_service.submit_finetune(req, llm)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/finetune/status/{job_id}", response_model=FinetuneStatusResponse)
|
|
|
|
|
async def get_status(
|
|
|
|
|
job_id: str,
|
|
|
|
|
llm: LLMClient = Depends(get_llm_client),
|
|
|
|
|
) -> FinetuneStatusResponse:
|
|
|
|
|
return await finetune_service.get_finetune_status(job_id, llm)
|