Skip to content

Commit

Permalink
Update openai.py
Browse files Browse the repository at this point in the history
Use hasattr instead of checking for choices in response
  • Loading branch information
rlnasuti authored Oct 20, 2023
1 parent d52dcff commit 0628cd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backend/chainlit/playground/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def create_completion(self, request):

async def create_event_stream():
async for stream_resp in response:
if 'choices' in stream_resp and len(stream_resp.choices) > 0:
if hasattr(stream_resp, 'choices') and len(stream_resp.choices) > 0:
token = stream_resp.choices[0]["delta"].get("content", "")
yield token
else:
Expand Down

0 comments on commit 0628cd6

Please sign in to comment.