openai[patch]: perform judgment processing on chat model streaming delta (#18983)

**PR title:** partners: openai chat model
**PR message:** perform judgment processing on chat model streaming
delta
Closes #18977

Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
HuangZiy 2024-03-29 05:46:27 +08:00 committed by GitHub
parent b7c8bc8268
commit e1f10a697e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -463,6 +463,8 @@ class ChatOpenAI(BaseChatModel):
if len(chunk["choices"]) == 0:
continue
choice = chunk["choices"][0]
if choice["delta"] is None:
continue
chunk = _convert_delta_to_message_chunk(
choice["delta"], default_chunk_class
)
@ -557,6 +559,8 @@ class ChatOpenAI(BaseChatModel):
if len(chunk["choices"]) == 0:
continue
choice = chunk["choices"][0]
if choice["delta"] is None:
continue
chunk = _convert_delta_to_message_chunk(
choice["delta"], default_chunk_class
)