Spaces:
Sleeping
Sleeping
Download src/models.py from InduwaraR/Interest_Predictions: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/InduwaraR/Interest_Predictions/resolve/main/src/models.py
- Command line
-
hf download hf://spaces/InduwaraR/Interest_Predictions/src/models.py
-
curl -L -o models.py https://huggingface.co/spaces/InduwaraR/Interest_Predictions/resolve/main/src/models.py
1.07 kB
| from pydantic import BaseModel, field_validator | |
| from typing import List | |
| class PredictionRequest(BaseModel): | |
| """Request model for prediction endpoint.""" | |
| answers: List[int] | |
| 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 |