Merge pull request #341 from naman1608/handle-none-types

handle none type in llm.py
This commit is contained in:
Abi Raja 2024-05-31 15:04:32 -04:00 committed by GitHub
commit 5a62fce52d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,9 +59,10 @@ async def stream_openai_response(
full_response = ""
async for chunk in stream: # type: ignore
assert isinstance(chunk, ChatCompletionChunk)
content = chunk.choices[0].delta.content or ""
full_response += content
await callback(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 ""
full_response += content
await callback(content)
await client.close()