This commit is contained in:
Timothy Jaeryang Baek
2026-07-16 21:57:43 -04:00
parent a2000df253
commit 743b9fd3ce
12 changed files with 98 additions and 91 deletions
@@ -248,6 +248,21 @@ class ChatMessageTable:
message = await db.get(ChatMessage, id)
return ChatMessageModel.model_validate(message) if message else None
async def has_unfinished_assistant_by_chat_id(
self,
chat_id: str,
db: Optional[AsyncSession] = None,
) -> bool:
async with get_async_db_context(db) as db:
result = await db.execute(
select(ChatMessage.id)
.where(ChatMessage.chat_id == chat_id)
.where(ChatMessage.role == 'assistant')
.where(ChatMessage.done.is_(False))
.limit(1)
)
return result.scalar_one_or_none() is not None
async def get_messages_by_chat_id(self, chat_id: str, db: Optional[AsyncSession] = None) -> list[ChatMessageModel]:
async with get_async_db_context(db) as db:
result = await db.execute(
+1
View File
@@ -186,6 +186,7 @@ class ChatTitleIdResponse(BaseModel):
created_at: int
last_read_at: int | None = None
snippet: str | None = None
active: bool = False
class SharedChatResponse(BaseModel):