Skip to content

Commit

Permalink
[Bug]: When use OpenAI chat model , raise ERROR: 'CompletionUsage' ob…
Browse files Browse the repository at this point in the history
…ject 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
#2948

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: Kevin Hu <[email protected]>
  • Loading branch information
yqwang96 and KevinHuSh authored Oct 22, 2024
1 parent b2524ee commit 5aa9d77
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions rag/llm/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def chat_streamly(self, system, history, gen_conf):
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 = (
Expand Down

0 comments on commit 5aa9d77

Please sign in to comment.