Spaces:
Running
Running
File size: 880 Bytes
b68e1c5 |
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 |
from enum import Enum
from typing import List
from pydantic import BaseModel, field_validator, model_validator
class ChatMessage(BaseModel):
role: str
content: str
class MediaType(str, Enum):
MOVIE = "movies"
TV = "tvs"
class ChatRequest(BaseModel):
question: str
history: List[ChatMessage] = []
media_type: MediaType = MediaType.MOVIE
genres: List[str] = []
providers: List[str] = []
year_range: List[int] = [1920, 2025]
@field_validator("question")
def validate_question(cls, v):
if not v.strip():
raise ValueError("Question cannot be empty")
return v
@model_validator(mode="after")
def validate_year_range(self) -> "ChatRequest":
if len(self.year_range) != 2:
raise ValueError("year_range must be a list of exactly two integers: [start, end]")
return self
|