RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix miscalculated token count (#9776)
Yuhao Bi91d6fb8061dc
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.pyindex 98d71141c8..adc4a3c5af 100644--- a/rag/llm/chat_model.py+++ b/rag/llm/chat_model.py@@ -374,7 +374,7 @@ class Base(ABC):if not tol:total_tokens += num_tokens_from_string(resp.choices[0].delta.content)else:- total_tokens += tol+ total_tokens = tolfinish_reason = resp.choices[0].finish_reason if hasattr(resp.choices[0], "finish_reason") else ""if finish_reason == "length":@@ -410,7 +410,7 @@ class Base(ABC):if not tol:total_tokens += num_tokens_from_string(resp.choices[0].delta.content)else:- total_tokens += tol+ total_tokens = tolanswer += resp.choices[0].delta.contentyield resp.choices[0].delta.content