Files
bakery-ia/services/training/app/api/models.py
2025-07-26 23:29:57 +02:00

36 lines
1.0 KiB
Python

"""
Models API endpoints
"""
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List
import structlog
from app.core.database import get_db
from app.schemas.training import TrainedModelResponse
from app.services.training_service import TrainingService
from shared.auth.decorators import (
get_current_tenant_id_dep
)
logger = structlog.get_logger()
router = APIRouter()
training_service = TrainingService()
@router.get("/tenants/{tenant_id}/", response_model=List[TrainedModelResponse])
async def get_trained_models(
tenant_id: str = Depends(get_current_tenant_id_dep),
db: AsyncSession = Depends(get_db)
):
"""Get trained models"""
try:
return await training_service.get_trained_models(tenant_id, db)
except Exception as e:
logger.error(f"Get trained models error: {e}")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Failed to get trained models"
)