Skip to content

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

fix: tighten embedding truncation threshold (#16123)

buua43678b4906f7af2
diff --git a/api/db/services/llm_service.py b/api/db/services/llm_service.py
index 02852fa137..f651729806 100644
--- a/api/db/services/llm_service.py
+++ b/api/db/services/llm_service.py
@@ -137,7 +137,7 @@ class LLMBundle(LLM4Tenant):
safe_texts.append("None")
continue
token_size = num_tokens_from_string(text)
- if token_size > self.max_length:
+ if token_size > self.max_length * 0.95:
target_len = int(self.max_length * 0.95)
safe_texts.append(text[:target_len])
else: