fix: streaming token mode cannot work in function calls and will infi… (#5396)

Fix: Prevent empty messages accumulation in streaming mode

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
so2liu 2025-02-08 02:42:27 +08:00 committed by GitHub
parent 901ab1276d
commit 07c5dc7514
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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