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