Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: truncate message issue. (#5776)

Kevin Hu2ad852d8dfb4
diff --git a/rag/prompts.py b/rag/prompts.py
index 6bc6a4659c..32ef5325e3 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