InduwaraR's picture
deploy ml model
523415f
Raw History Blame Contribute Delete
1.07 kB
from pydantic import BaseModel, field_validator
from typing import List
class PredictionRequest(BaseModel):
"""Request model for prediction endpoint."""
answers: List[int]
@field_validator('answers')
@classmethod
def validate_answers(cls, v):
if len(v) != 10:
raise ValueError(f'Must provide exactly 10 answers, got {len(v)}')
for i, answer in enumerate(v, 1):
if not isinstance(answer, int) or not 1 <= answer <= 5:
raise ValueError(f'Answer {i} must be an integer between 1 and 5, got {answer}')
return v
class PredictionResponse(BaseModel):
"""Response model for prediction endpoint."""
success: bool
prediction: str
# confidence: float = None
message: str = None
class QuestionsResponse(BaseModel):
"""Response model for questions endpoint."""
questions: List[str]
total_questions: int
class HealthResponse(BaseModel):
"""Response model for health check."""
status: str
model_loaded: bool
message: str