From 414d9c3227515949ad1923bb11d71b1cf4e86e0a Mon Sep 17 00:00:00 2001 From: wd0517 Date: Tue, 7 Jan 2025 06:14:44 +0000 Subject: [PATCH] fix(backend): fix chat endpoint when chat id does not exists --- backend/app/exceptions.py | 4 +++- backend/app/rag/chat.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/exceptions.py b/backend/app/exceptions.py index 29d4973f..9f6e2c7e 100644 --- a/backend/app/exceptions.py +++ b/backend/app/exceptions.py @@ -1,4 +1,6 @@ from http import HTTPStatus +from uuid import UUID + from fastapi import HTTPException # Common @@ -19,7 +21,7 @@ class ChatException(HTTPException): class ChatNotFound(ChatException): status_code = 404 - def __init__(self, chat_id: int): + def __init__(self, chat_id: UUID): self.detail = f"chat #{chat_id} is not found" diff --git a/backend/app/rag/chat.py b/backend/app/rag/chat.py index f58c8397..33391230 100644 --- a/backend/app/rag/chat.py +++ b/backend/app/rag/chat.py @@ -113,7 +113,7 @@ def __init__( # anonymous user can only access anonymous chat by track_id self.db_chat_obj = chat_repo.get(self.db_session, chat_id) if not self.db_chat_obj: - raise ChatNotFound() + raise ChatNotFound(chat_id) try: self.chat_engine_config = ChatEngineConfig.load_from_db( db_session, self.db_chat_obj.engine.name