check if attribute choices is present (#535)

This commit is contained in:
Abhijit Balaji 2023-10-05 22:46:51 -06:00 • committed by GitHub
parent e7c9b0fa42
commit 134ee46f5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -134,7 +134,7 @@ class OpenAI(LLM):
stream=True,
**args,
):
if len(chunk.choices) == 0:
if not hasattr(chunk, "choices") or len(chunk.choices) == 0:
continue
yield chunk.choices[0].delta