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.
This commit is contained in:
Debanjum
2025-07-10 23:48:16 -07:00
parent c8ec29551f
commit 25db59e49c

View File

@@ -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: