From 5aa9d7787ed0f9aa10da50db33b1078ac88bcd30 Mon Sep 17 00:00:00 2001 From: Yinquan WANG <81215927+yqwang96@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:40:05 +0800 Subject: [PATCH] [Bug]: When use OpenAI chat model , raise ERROR: 'CompletionUsage' object has no attribute 'get' #2948 (#2949) [Bug]: When use OpenAI chat model , raise ERROR: 'CompletionUsage' object has no attribute 'get' #2948 ### What problem does this PR solve? the detail of this PR is shown at https://github.com/infiniflow/ragflow/issues/2948 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: Kevin Hu --- rag/llm/chat_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index 58d5b0ded..1dbf50935 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -67,6 +67,7 @@ class Base(ABC): if not resp.choices[0].delta.content: resp.choices[0].delta.content = "" ans += resp.choices[0].delta.content + total_tokens += 1 if not hasattr(resp, "usage") or not resp.usage: total_tokens = (