from .imports import *

class ChatBody(BaseModel):
    model_key: Optional[str] = None
    prompt: Optional[str] = None
    messages: Optional[List[dict]] = None      # kept for the day the frontend uncomments
    max_new_tokens: int = 2048
    temperature: Optional[float] = None
    do_sample: Optional[bool] = None

    @model_validator(mode="after")
    def _require_one_input(self):
        if not self.prompt and not self.messages:
            raise ValueError("ChatBody needs either 'prompt' or 'messages'")
        return self
    
class Message(BaseModel):
    role: str
    content: str
    images: List[str] | None = None
    file: str | None = None     # server path from /api/uploads
