Improve structured message truncation in logger

Previously chatml messages were just strings.
Since gemini, anthropic models always have messages as list of
strings, truncate those strings instead of the list of message content
This commit is contained in:
Debanjum 2024-11-12 21:40:39 -08:00
parent 153ae8bea9
commit 15b0cfa3dd
2 changed files with 2 additions and 2 deletions

View file

@ -215,7 +215,7 @@ def converse_anthropic(
messages, system_prompt = format_messages_for_anthropic(messages, system_prompt) messages, system_prompt = format_messages_for_anthropic(messages, system_prompt)
truncated_messages = "\n".join({f"{message.content[:40]}..." for message in messages}) truncated_messages = "\n".join({f"{content[:70]}..." for message in messages for content in message.content})
logger.debug(f"Conversation Context for Claude: {truncated_messages}") logger.debug(f"Conversation Context for Claude: {truncated_messages}")
# Get Response from Claude # Get Response from Claude

View file

@ -226,7 +226,7 @@ def converse_gemini(
messages, system_prompt = format_messages_for_gemini(messages, system_prompt) messages, system_prompt = format_messages_for_gemini(messages, system_prompt)
truncated_messages = "\n".join({f"{message.content[:40]}..." for message in messages}) truncated_messages = "\n".join({f"{content[:70]}..." for message in messages for content in message.content})
logger.debug(f"Conversation Context for Gemini: {truncated_messages}") logger.debug(f"Conversation Context for Gemini: {truncated_messages}")
# Get Response from Google AI # Get Response from Google AI