From 64c6cc4cf3d0a915980c7630bdb0fa0ac7431b69 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Fri, 7 Mar 2025 16:33:25 +0800 Subject: [PATCH] Fix: truncate message issue. (#5765) ### What problem does this PR solve? Close #5761 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/prompts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rag/prompts.py b/rag/prompts.py index 7c0f23be9..6bc6a4659 100644 --- a/rag/prompts.py +++ b/rag/prompts.py @@ -70,7 +70,7 @@ def message_fit_in(msg, max_length=4000): if c < max_length: return c, msg - msg_ = [m for m in msg[:-1] if m["role"] == "system"] + msg_ = [m for m in msg if m["role"] == "system"] if len(msg) > 1: msg_.append(msg[-1]) msg = msg_