Mercurial
view love/poppy/db/models.py @ 279:b3b547563ec7
Add Google connector service and agent wiki
Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 17 Aug 2026 22:22:36 -0700 |
| parents | cf9caa4abc3e |
| children |
line wrap: on
line source
from sqlmodel import SQLModel, Field, Relationship from typing import Optional, List from datetime import datetime import uuid from sqlalchemy import text class MessageAsset(SQLModel, table=True): id: uuid.UUID = Field( default_factory=uuid.uuid4, primary_key=True, index=True, nullable=False, sa_column_kwargs={"server_default": text("gen_random_uuid()")}, ) message_id: uuid.UUID = Field(foreign_key="message.id", index=True) asset_type: str = Field(index=True) # "image" | "file" | "audio" | "video" | etc. url: str = Field() # public or signed URL # Pretty good suggestions but not needed for now. # filename: Optional[str] = Field(default=None) # mime_type: Optional[str] = Field(default=None) # width: Optional[int] = Field(default=None) # for images/videos # height: Optional[int] = Field(default=None) # size_bytes: Optional[int] = Field(default=None) # alt_text: Optional[str] = Field(default=None) # user-provided description created_at: datetime = Field(default_factory=datetime.utcnow, nullable=False) # Relationship back to message message: "Message" = Relationship(back_populates="assets") class Message(SQLModel, table=True): id: uuid.UUID = Field( default_factory=uuid.uuid4, primary_key=True, index=True, nullable=False, sa_column_kwargs={"server_default": text("gen_random_uuid()")}, ) chat_id: uuid.UUID = Field(foreign_key="chat.id") role: str = Field( index=True ) # "user" | "assistant" TODO: use enum? I don't mind just defining like this tho. content: str created_at: datetime = Field(default_factory=datetime.utcnow, nullable=False) # Relationship chat: Optional["Chat"] = Relationship(back_populates="messages") assets: List[MessageAsset] = Relationship(back_populates="message") class Chat(SQLModel, table=True): id: uuid.UUID = Field( default_factory=uuid.uuid4, primary_key=True, index=True, nullable=False, sa_column_kwargs={"server_default": text("gen_random_uuid()")}, ) title: str = Field(default="New Chat") created_at: datetime = Field(default_factory=datetime.utcnow, nullable=False) # Relationship messages: List[Message] = Relationship( back_populates="chat", sa_relationship_kwargs={"cascade": "all, delete-orphan"} )