Yinquan WANG Kevin Hu commited on
Commit
8efa7c5
·
1 Parent(s): 0dbe613

[Bug]: When use OpenAI chat model , raise ERROR: 'CompletionUsage' object has no attribute 'get' #2948 (#2949)

Browse files

[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 <[email protected]>

Files changed (1) hide show
  1. rag/llm/chat_model.py +1 -0
rag/llm/chat_model.py CHANGED
@@ -67,6 +67,7 @@ class Base(ABC):
67
  if not resp.choices[0].delta.content:
68
  resp.choices[0].delta.content = ""
69
  ans += resp.choices[0].delta.content
 
70
  total_tokens += 1
71
  if not hasattr(resp, "usage") or not resp.usage:
72
  total_tokens = (
 
67
  if not resp.choices[0].delta.content:
68
  resp.choices[0].delta.content = ""
69
  ans += resp.choices[0].delta.content
70
+
71
  total_tokens += 1
72
  if not hasattr(resp, "usage") or not resp.usage:
73
  total_tokens = (