Skip to content

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

feat: 优化判断逻辑

huangpeilina473c74c902b
diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py
index cc1a4fc8b..68dc156c2 100644
--- a/metagpt/provider/openai_api.py
+++ b/metagpt/provider/openai_api.py
@@ -100,7 +100,7 @@ class OpenAILLM(BaseLLM):
log_llm_stream(chunk_message)
collected_messages.append(chunk_message)
if finish_reason:
- if hasattr(chunk, "usage") and 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"):