From 2ad852d8dfb45bc73fdb398052943d22199e44f8 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Fri, 7 Mar 2025 17:41:56 +0800 Subject: [PATCH] Fix: truncate message issue. (#5776) ### What problem does this PR solve? Close #5761 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/prompts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rag/prompts.py b/rag/prompts.py index 6bc6a4659..32ef5325e 100644 --- a/rag/prompts.py +++ b/rag/prompts.py @@ -86,9 +86,9 @@ def message_fit_in(msg, max_length=4000): msg[0]["content"] = m return max_length, msg - m = msg_[1]["content"] + m = msg_[-1]["content"] m = encoder.decode(encoder.encode(m)[:max_length - ll2]) - msg[1]["content"] = m + msg[-1]["content"] = m return max_length, msg