Mercurial
comparison love/poppy/utils/models.py @ 38:cf9caa4abc3e
[Love] FE and BE. Can chat and render images. Also created MCP for powerpoint generations.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 01 Dec 2025 20:35:56 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 37:fb9bcd3145cb | 38:cf9caa4abc3e |
|---|---|
| 1 from sqlmodel import SQLModel, Field, Relationship | |
| 2 from typing import Optional, List | |
| 3 from datetime import datetime | |
| 4 | |
| 5 | |
| 6 class Message(SQLModel, table=True): | |
| 7 id: Optional[int] = Field(default=None, primary_key=True) | |
| 8 chat_id: int = Field(foreign_key="chat.id") | |
| 9 role: str = Field(index=True) # "user" | "assistant" | |
| 10 content: str | |
| 11 created_at: datetime = Field(default_factory=datetime.utcnow) | |
| 12 | |
| 13 chat: Optional["Chat"] = Relationship(back_populates="messages") | |
| 14 | |
| 15 | |
| 16 class Chat(SQLModel, table=True): | |
| 17 id: Optional[int] = Field(default=None, primary_key=True) | |
| 18 title: str = Field(default="New Chat") | |
| 19 created_at: datetime = Field(default_factory=datetime.utcnow) | |
| 20 | |
| 21 messages: List[Message] = Relationship(back_populates="chat") |