From 35d6c792e4475c0286a330093a8dce59719811a6 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Mon, 11 Nov 2024 02:30:38 -0800 Subject: [PATCH] Show snippet of truncated messages in debug logs to avoid log flooding --- src/khoj/processor/conversation/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index 0aaaa4b3..1f43aa80 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -449,7 +449,7 @@ def truncate_messages( truncated_message = encoder.decode(encoder.encode(original_question)[:remaining_tokens]).strip() messages = [ChatMessage(content=truncated_message, role=messages[0].role)] 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: