Spaces:
Sleeping
Sleeping
File size: 1,624 Bytes
c09e844 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
"""
Pydantic Schemas for Request/Response Validation
"""
from pydantic import BaseModel, EmailStr, Field
from typing import Optional, List
from datetime import datetime
# ===== Auth Schemas =====
class UserCreate(BaseModel):
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
password: str = Field(..., min_length=6)
class UserLogin(BaseModel):
username: str
password: str
class UserResponse(BaseModel):
id: int
username: str
email: str
created_at: datetime
class Config:
from_attributes = True
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
username: Optional[str] = None
# ===== Prediction Schemas =====
class SinglePredictionRequest(BaseModel):
product_name: Optional[str] = ""
comment: str
class SinglePredictionResponse(BaseModel):
predicted_rating: int
confidence_score: float
comment: str
class BatchPredictionResponse(BaseModel):
total_predictions: int
rating_distribution: dict
wordcloud_url: str
results: List[dict]
csv_download_url: str
pdf_download_url: str
class PDFReportRequest(BaseModel):
predictions: List[dict]
distribution: dict
wordcloud_path: str
# ===== History Schemas =====
class PredictionHistoryResponse(BaseModel):
id: int
product_name: str
comment: str
predicted_rating: int
confidence_score: Optional[float]
prediction_type: str
created_at: datetime
class Config:
from_attributes = True
|