30 lines
820 B
Python
30 lines
820 B
Python
from fastapi import APIRouter, HTTPException, Request
|
|
|
|
from app.models.training import TrainingStatus
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/status", response_model=TrainingStatus)
|
|
async def get_training_status(request: Request):
|
|
"""
|
|
Get current training status including progress, loss, and learning rate
|
|
"""
|
|
try:
|
|
monitor = request.app.state.training_monitor
|
|
return await monitor.get_status()
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
@router.get("/log")
|
|
async def get_training_log(request: Request):
|
|
"""
|
|
Get recent training log entries
|
|
"""
|
|
try:
|
|
monitor = request.app.state.training_monitor
|
|
return await monitor.get_log()
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|