From 07c5dc751485d49bf93d4c57e841dc6ea6a24757 Mon Sep 17 00:00:00 2001 From: so2liu Date: Sat, 8 Feb 2025 02:42:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20streaming=20token=20mode=20cannot=20work?= =?UTF-8?q?=20in=20function=20calls=20and=20will=20infi=E2=80=A6=20(#5396)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: Prevent empty messages accumulation in streaming mode Co-authored-by: Eric Zhu --- .../autogen-ext/src/autogen_ext/models/openai/_openai_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py index e6f8da279..b1f23e104 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py @@ -767,7 +767,7 @@ class BaseOpenAIChatCompletionClient(ChatCompletionClient): stop_reason = choice.finish_reason if chunk.usage is None and stop_reason is None else stop_reason maybe_model = chunk.model # First try get content - if choice.delta.content is not None: + if choice.delta.content: content_deltas.append(choice.delta.content) if len(choice.delta.content) > 0: yield choice.delta.content