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
  • Loading branch information
yqwang96 authored Oct 22, 2024
1 parent 6a4858a commit f27c7b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rag/llm/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def chat_streamly(self, system, history, gen_conf):
+ num_tokens_from_string(resp.choices[0].delta.content)
)
if not hasattr(resp, "usage") or not resp.usage
else resp.usage.get("total_tokens", total_tokens)
else dict(resp.usage).get('total_tokens', total_tokens)
)
if resp.choices[0].finish_reason == "length":
ans += "...\nFor the content length reason, it stopped, continue?" if is_english(
Expand Down

0 comments on commit f27c7b6

Please sign in to comment.