Skip to content

Commit 899c5bb

Browse files
Print raw OpenAI server errors
1 parent 8afac4b commit 899c5bb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/poet_chat/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ async def _openai_recv():
4747
raise RuntimeError("Unexpected error from OpenAI API!")
4848
elif event.data.type == "exception":
4949
raise event.data.exception
50+
elif event.data.type == "raw_server_event":
51+
match event.data.data:
52+
case {"response": {"status": "failed"}}:
53+
print(event.data.data)
54+
raise RuntimeError("Raw server error from OpenAI API!")
5055

5156
async def _fishjam_recv():
5257
async for event in fishjam_session.receive():

0 commit comments

Comments
 (0)