Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

update openai_api.py

better629e094e2a61540
diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py
index ce3a06ec8..1d2057e50 100644
--- a/metagpt/provider/openai_api.py
+++ b/metagpt/provider/openai_api.py
@@ -103,7 +103,7 @@ class OpenAILLM(BaseLLM):
if has_finished:
# for oneapi, there has a usage chunk after finish_reason not none chunk
if chunk_has_usage:
- usage = CompletionUsage(**chunk.usage)
+ usage = CompletionUsage(**chunk.usage) if isinstance(chunk.usage, dict) else chunk.usage
if finish_reason:
if chunk_has_usage:
# Some services have usage as an attribute of the chunk, such as Fireworks