From 25db59e49cb83256b936b743638badfb107ed17f Mon Sep 17 00:00:00 2001 From: Debanjum Date: Thu, 10 Jul 2025 23:48:16 -0700 Subject: [PATCH] Fix to return openai formatted messages in the correct order We'd reversed the formatting of openai messages to drop invalid messages without affecting the other messages being appended . But we need to reverse the final formatted list to return in the right order. --- src/khoj/processor/conversation/openai/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/khoj/processor/conversation/openai/utils.py b/src/khoj/processor/conversation/openai/utils.py index 1ccb014d..33461523 100644 --- a/src/khoj/processor/conversation/openai/utils.py +++ b/src/khoj/processor/conversation/openai/utils.py @@ -443,7 +443,7 @@ def format_message_for_api(raw_messages: List[ChatMessage], api_base_url: str) - continue formatted_messages.append({"role": message.role, "content": message.content}) - return formatted_messages + return list(reversed(formatted_messages)) def is_openai_api(api_base_url: str = None) -> bool: