Skip to content

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

fix: ERROR: 'CompletionUsage' object has no attribute 'get' (#1736)

Wang Baoling74ebc497c1c3
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py
index 9337bd6bf1..fb6fca8b21 100644
--- a/rag/llm/chat_model.py
+++ b/rag/llm/chat_model.py
@@ -183,7 +183,7 @@ class BaiChuanChat(Base):
if resp.choices[0].finish_reason == "stop":
if not resp.choices[0].delta.content:
continue
- total_tokens = resp.usage.get('total_tokens', 0)
+ total_tokens = resp.usage.total_tokens
if not resp.choices[0].delta.content:
continue
ans += resp.choices[0].delta.content