mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
Update openai_api.py
This commit is contained in:
parent
31e0a46e6a
commit
25679346dc
1 changed files with 1 additions and 1 deletions
|
|
@ -103,7 +103,7 @@ class OpenAILLM(BaseLLM):
|
|||
if finish_reason:
|
||||
if hasattr(chunk, "usage"):
|
||||
# Some services have usage as an attribute of the chunk, such as Fireworks
|
||||
usage = CompletionUsage(**chunk.usage)
|
||||
usage = CompletionUsage(**chunk.usage) if isinstance(chunk.usage, dict) else chunk.usage
|
||||
elif hasattr(chunk.choices[0], "usage"):
|
||||
# The usage of some services is an attribute of chunk.choices[0], such as Moonshot
|
||||
usage = CompletionUsage(**chunk.choices[0].usage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue