Update chats.py

Change to pass CI
This commit is contained in:
PVBLIC Foundation 2025-05-30 20:21:21 -07:00 committed by GitHub
parent bcc2d7233d
commit af97737b0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,10 +33,11 @@ class DatabaseType(Enum):
Used by DatabaseAdapter to determine optimal query strategies and
features available for each database backend.
"""
SQLITE = "sqlite" # SQLite with JSON1 extension
SQLITE = "sqlite" # SQLite with JSON1 extension
POSTGRESQL_JSON = "postgresql_json" # PostgreSQL with standard JSON
POSTGRESQL_JSONB = "postgresql_jsonb" # PostgreSQL with binary JSONB
UNSUPPORTED = "unsupported" # Unsupported database type
UNSUPPORTED = "unsupported" # Unsupported database type
class DatabaseAdapter:
@ -266,7 +267,7 @@ class Chat(Base):
# Sharing functionality - UUID for shared public links
share_id = Column(Text, unique=True, nullable=True)
# Organization and state flags
archived = Column(Boolean, default=False) # Hidden from main view
archived = Column(Boolean, default=False) # Hidden from main view
pinned = Column(Boolean, default=False, nullable=True) # Pinned to top
# Extensible metadata storage (tags, custom fields, etc.)
@ -291,13 +292,13 @@ class ChatModel(BaseModel):
updated_at: int # timestamp in epoch
# Optional fields with defaults
share_id: Optional[str] = None # Public sharing identifier
archived: bool = False # Archive status
pinned: Optional[bool] = False # Pin status (nullable for compatibility)
share_id: Optional[str] = None # Public sharing identifier
archived: bool = False # Archive status
pinned: Optional[bool] = False # Pin status (nullable for compatibility)
# Extensible fields
meta: dict = {} # Metadata including tags
folder_id: Optional[str] = None # Folder organization
meta: dict = {} # Metadata including tags
folder_id: Optional[str] = None # Folder organization
####################
@ -312,6 +313,7 @@ class ChatForm(BaseModel):
Used for API endpoints that create new chat conversations.
Validates that the required chat data structure is present.
"""
chat: dict
@ -325,9 +327,10 @@ class ChatImportForm(ChatForm):
Extends ChatForm with optional metadata fields that are not
required for basic chat creation but useful for import scenarios.
"""
meta: Optional[dict] = {} # Tags and other metadata
pinned: Optional[bool] = False # Pin status
folder_id: Optional[str] = None # Folder assignment
meta: Optional[dict] = {} # Tags and other metadata
pinned: Optional[bool] = False # Pin status
folder_id: Optional[str] = None # Folder assignment
class ChatTitleMessagesForm(BaseModel):
@ -337,6 +340,7 @@ class ChatTitleMessagesForm(BaseModel):
Used by endpoints that work with chat titles and message lists
independently, such as chat generation or title updates.
"""
title: str
messages: list[dict]
@ -348,6 +352,7 @@ class ChatTitleForm(BaseModel):
Used by endpoints that only modify the chat title without
affecting the conversation content or metadata.
"""
title: str
@ -362,6 +367,7 @@ class ChatResponse(BaseModel):
Used by endpoints that return full chat information to ensure
consistent response structure across the API.
"""
# Core chat identification and data
id: str
user_id: str
@ -372,11 +378,11 @@ class ChatResponse(BaseModel):
created_at: int # timestamp in epoch
# Sharing and organization
share_id: Optional[str] = None # id of the chat to be shared
archived: bool # archive status
archived: bool # archive status
pinned: Optional[bool] = False # pin status
# Extensible metadata and organization
meta: dict = {} # tags and other metadata
folder_id: Optional[str] = None # folder assignment
meta: dict = {} # tags and other metadata
folder_id: Optional[str] = None # folder assignment
class ChatTitleIdResponse(BaseModel):
@ -390,6 +396,7 @@ class ChatTitleIdResponse(BaseModel):
Used by endpoints that return chat lists, search results, or
navigation menus where full chat content is not needed.
"""
id: str
title: str
updated_at: int