From 3b978b9b6765fee055b80da0631924e0173dddd2 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 23 Oct 2024 03:40:01 -0700 Subject: [PATCH] Fix chat history construction when generating chatml msgs with context --- src/khoj/processor/conversation/utils.py | 2 +- src/khoj/routers/api_chat.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index bc5b2c2e..1ccc7594 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -203,7 +203,7 @@ def generate_chatml_messages_with_context( chatml_messages.insert(0, reconstructed_context_message) role = "user" if chat["by"] == "you" else "assistant" - message_content = construct_structured_message(message_content, chat.get("images"), model_type, vision_enabled) + message_content = construct_structured_message(chat["message"], chat.get("images"), model_type, vision_enabled) reconstructed_message = ChatMessage(content=message_content, role=role) chatml_messages.insert(0, reconstructed_message) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 09ea9eea..3cc541b1 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -112,7 +112,7 @@ def add_files_filter(request: Request, filter: FilesFilterRequest): file_filters = ConversationAdapters.add_files_to_filter(request.user.object, conversation_id, files_filter) return Response(content=json.dumps(file_filters), media_type="application/json", status_code=200) except Exception as e: - logger.error(f"Error adding file filter {filter.filename}: {e}", exc_info=True) + logger.error(f"Error adding file filter {filter.filenames}: {e}", exc_info=True) raise HTTPException(status_code=422, detail=str(e))