from pydantic import BaseModel, Field, ConfigDict # <-- Add ConfigDict here from typing import List, Literal, Optional from datetime import datetime # --- Chat Schemas --- class ChatRequest(BaseModel): """Defines the shape of a request to the /chat endpoint.""" prompt: str = Field(..., min_length=1) # The 'model' is now part of the Session, but we can keep it here for stateless requests if needed. # For session-based chat, this field might be ignored. model: Literal["deepseek", "gemini"] = Field("deepseek") class ChatResponse(BaseModel): """Defines the shape of a successful response from the /chat endpoint.""" answer: str model_used: str # --- Document Schemas --- class DocumentCreate(BaseModel): title: str text: str source_url: Optional[str] = None author: Optional[str] = None user_id: str = "default_user" class DocumentResponse(BaseModel): message: str class DocumentInfo(BaseModel): id: int title: str source_url: Optional[str] = None status: str created_at: datetime model_config = ConfigDict(from_attributes=True) class DocumentListResponse(BaseModel): documents: List[DocumentInfo] class DocumentDeleteResponse(BaseModel): message: str document_id: int # --- Session Schemas --- class SessionCreate(BaseModel): """Defines the shape for starting a new conversation session.""" user_id: str model: Literal["deepseek", "gemini"] = "deepseek" class Session(BaseModel): """Defines the shape of a session object returned by the API.""" id: int user_id: str title: str model_name: str created_at: datetime model_config = ConfigDict(from_attributes=True)