Previously loaded the entire ChatModel (including the full conversation JSON blob) just to extract the title string. Now queries only the Chat.title column directly, which is already a top-level DB column.
This commit is contained in:
@@ -456,11 +456,11 @@ class ChatTable:
|
|||||||
return ChatModel.model_validate(chat)
|
return ChatModel.model_validate(chat)
|
||||||
|
|
||||||
def get_chat_title_by_id(self, id: str) -> Optional[str]:
|
def get_chat_title_by_id(self, id: str) -> Optional[str]:
|
||||||
chat = self.get_chat_by_id(id)
|
with get_db_context() as db:
|
||||||
if chat is None:
|
result = db.query(Chat.title).filter_by(id=id).first()
|
||||||
return None
|
if result is None:
|
||||||
|
return None
|
||||||
return chat.chat.get("title", "New Chat")
|
return result[0] or "New Chat"
|
||||||
|
|
||||||
def get_messages_map_by_chat_id(self, id: str) -> Optional[dict]:
|
def get_messages_map_by_chat_id(self, id: str) -> Optional[dict]:
|
||||||
chat = self.get_chat_by_id(id)
|
chat = self.get_chat_by_id(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user