35 lines
591 B
Python
35 lines
591 B
Python
from pydantic import BaseModel
|
|
from typing import List, Optional
|
|
from datetime import datetime
|
|
|
|
class MessageBase(BaseModel):
|
|
role: str
|
|
content: str
|
|
|
|
class MessageOut(MessageBase):
|
|
id: int
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class ChatBase(BaseModel):
|
|
title: str
|
|
|
|
class ChatOut(ChatBase):
|
|
id: int
|
|
messages: List[MessageOut] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class UserOut(BaseModel):
|
|
id: int
|
|
telegram_id: str
|
|
username: Optional[str]
|
|
chats: List[ChatOut] = []
|
|
|
|
class Config:
|
|
orm_mode = True |