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

### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Wang Baoling 2024-07-30 15:12:16 +08:00 committed by GitHub
parent 161cb08bbd
commit 74ebc497c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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