Skip to content

Commit

Permalink
Merge pull request #1253 from aa875982361/fix/none-usage
Browse files Browse the repository at this point in the history
fix: failure when usage is none
  • Loading branch information
garylin2099 committed May 14, 2024
2 parents da0e47b + a473c74 commit 00e1c93
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion metagpt/provider/openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def _achat_completion_stream(self, messages: list[dict], timeout=USE_CONFI
log_llm_stream(chunk_message)
collected_messages.append(chunk_message)
if finish_reason:
if hasattr(chunk, "usage"):
if hasattr(chunk, "usage") and chunk.usage is not None:
# Some services have usage as an attribute of the chunk, such as Fireworks
usage = CompletionUsage(**chunk.usage)
elif hasattr(chunk.choices[0], "usage"):
Expand Down

0 comments on commit 00e1c93

Please sign in to comment.