aaa / app /api /v2 /risk.py
work-sejal
Deploy AI service with FastAPI
70ea7be
Raw
History Blame Contribute Delete
799 Bytes
"""Risk prediction API router.
Exposes GET /ai/v2/risk/{student_id} for student risk inference.
"""
from fastapi import APIRouter, Depends
from app.api.v2.dependencies import get_risk_service
from app.schemas.risk import RiskResponse
router = APIRouter(prefix="/ai/v2", tags=["inference"])
@router.get(
"/risk/{student_id}",
response_model=RiskResponse,
summary="Predict student risk level",
description=(
"Returns risk score, 4-class label, reasons, and recommended intervention "
"for a given student. Uses ML model with rule-based fallback."
),
)
async def predict_risk(
student_id: str,
service=Depends(get_risk_service),
) -> RiskResponse:
"""Predict risk score and label for a student."""
return service.predict(student_id=student_id)