From 253c7e581f99db181fa117e8b97282a3dee0a822 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 6 Nov 2024 16:41:13 +0100 Subject: [PATCH] fix(logging): add debug log for truncated messages Added a debug-level log statement to capture the final set of messages before returning, which aids in tracing message processing and debugging potential issues in the message truncation logic. This enhances transparency and facilitates easier troubleshooting. --- src/gptbot/classes/ai/openai.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gptbot/classes/ai/openai.py b/src/gptbot/classes/ai/openai.py index e6d2e94..52d117f 100644 --- a/src/gptbot/classes/ai/openai.py +++ b/src/gptbot/classes/ai/openai.py @@ -487,12 +487,16 @@ class OpenAI(BaseAI): ), } - return ( + final_messages = ( [system_message_dict] + [truncated_messages[0]] + list(reversed(truncated_messages[1:])) ) + self.logger.log(f"Truncated messages: {final_messages}", "debug") + + return final_messages + async def generate_chat_response( self, messages: List[Dict[str, str]],