null check for chunk.choices
This commit is contained in:
parent
c5695975c7
commit
f0ee686660
@ -59,7 +59,7 @@ async def stream_openai_response(
|
|||||||
full_response = ""
|
full_response = ""
|
||||||
async for chunk in stream: # type: ignore
|
async for chunk in stream: # type: ignore
|
||||||
assert isinstance(chunk, ChatCompletionChunk)
|
assert isinstance(chunk, ChatCompletionChunk)
|
||||||
if chunk.choices and chunk.choices[0].delta.content:
|
if chunk.choices and len(chunk.choices) > 0 and chunk.choices[0].delta and chunk.choices[0].delta.content:
|
||||||
content = chunk.choices[0].delta.content or ""
|
content = chunk.choices[0].delta.content or ""
|
||||||
full_response += content
|
full_response += content
|
||||||
await callback(content)
|
await callback(content)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user