Abeshith's picture
Add FastAPI application
5c61354
Raw
History Blame Contribute Delete
903 Bytes
from fastapi import APIRouter
from app.schemas.response import HealthResponse
from app.utils.model_loader import model_loader
router = APIRouter(prefix="/health", tags=["health"])
@router.get("/", response_model=HealthResponse)
async def health_check():
is_loaded = model_loader.is_loaded()
return HealthResponse(
status="healthy" if is_loaded else "degraded",
model_loaded=is_loaded,
message="Model loaded and ready" if is_loaded else "Model not loaded"
)
@router.get("/ready", response_model=HealthResponse)
async def readiness_check():
is_loaded = model_loader.is_loaded()
if not is_loaded:
return HealthResponse(
status="not_ready",
model_loaded=False,
message="Model not loaded"
)
return HealthResponse(
status="ready",
model_loaded=True,
message="Service ready"
)