[bug] fix chunk.choices[0].delta NoneType (#509)

* fix chunk.choices[0].delta NoneType

* Fix delta none on query calls

---------

Co-authored-by: Alonso Guevara <alonsog@microsoft.com>
This commit is contained in:
s106916 2024-07-12 12:50:57 +10:00 committed by GitHub
parent 53fcafd57f
commit ff7ac0512c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Fix delta none on query calls"
}

View File

@ -146,7 +146,10 @@ class ChatOpenAI(BaseLLM, OpenAILLMImpl):
if not chunk or not chunk.choices:
continue
delta = chunk.choices[0].delta.content or "" # type: ignore
delta = (
chunk.choices[0].delta.content if chunk.choices[0].delta else ""
) # type: ignore
full_response += delta
if callbacks:
for callback in callbacks:
@ -182,7 +185,10 @@ class ChatOpenAI(BaseLLM, OpenAILLMImpl):
if not chunk or not chunk.choices:
continue
delta = chunk.choices[0].delta.content or "" # type: ignore
delta = (
chunk.choices[0].delta.content if chunk.choices[0].delta else ""
) # type: ignore
full_response += delta
if callbacks:
for callback in callbacks: