File size: 1,472 Bytes
d60934b |
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 |
from pydantic import BaseModel, Field
from typing import Dict, List, Literal
from datetime import datetime
import uuid
class Message(BaseModel):
role: Literal["system", "user", "assistant"]
content: str
timestamp: datetime = Field(default_factory=datetime.utcnow)
class Conversation(BaseModel):
uid: str
messages: List[Message] = Field(default_factory=list)
last_interaction: datetime = Field(default_factory=datetime.utcnow)
class GuessingProgress(BaseModel):
indications: list[Message] = Field(default_factory=list)
guesses: list[str] = Field(default_factory=list)
class WagonProgress(BaseModel):
wagon_id: int = 0
conversations: Dict[str, Conversation] = Field(default_factory=dict)
theme: str = "Tutorial (Start)"
password: str = "start"
class UserSession(BaseModel):
session_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
current_wagon: WagonProgress = Field(default_factory=WagonProgress)
guessing_progress: GuessingProgress = Field(default_factory=GuessingProgress)
created_at: datetime = Field(default_factory=datetime.utcnow)
last_active: datetime = Field(default_factory=datetime.utcnow)
default_game: bool = Field(default=True)
class Config:
json_schema_extra = {
"example": {
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"current_wagon": {"wagon_id": 0, "conversations": {}},
}
}
|