Skip to content

Build and run agents you can see, understand and trust.

fix(chatmodel): fix a bug in `OpenAIChatModel` class that `choice.delta` maybe `None` sometimes (#1015)

qbc3b671788f143
diff --git a/src/agentscope/model/_openai_model.py b/src/agentscope/model/_openai_model.py
index bd6c6bca4..3655a8080 100644
--- a/src/agentscope/model/_openai_model.py
+++ b/src/agentscope/model/_openai_model.py
@@ -348,7 +348,7 @@ class OpenAIChatModel(ChatModelBase):
thinking += (
getattr(choice.delta, "reasoning_content", None) or ""
)
- text += choice.delta.content or ""
+ text += getattr(choice.delta, "content", None) or ""
if (
hasattr(choice.delta, "audio")