Show snippet of truncated messages in debug logs to avoid log flooding

This commit is contained in:
Debanjum 2024-11-11 02:30:38 -08:00
parent a5e2b9e745
commit 35d6c792e4

View file

@ -449,7 +449,7 @@ def truncate_messages(
truncated_message = encoder.decode(encoder.encode(original_question)[:remaining_tokens]).strip() truncated_message = encoder.decode(encoder.encode(original_question)[:remaining_tokens]).strip()
messages = [ChatMessage(content=truncated_message, role=messages[0].role)] messages = [ChatMessage(content=truncated_message, role=messages[0].role)]
logger.debug( logger.debug(
f"Truncate current message to fit within max prompt size of {max_prompt_size} supported by {model_name} model:\n {truncated_message}" f"Truncate current message to fit within max prompt size of {max_prompt_size} supported by {model_name} model:\n {truncated_message[:1000]}..."
) )
if system_message: if system_message: