Skip to content

Commit

Permalink
Merge pull request #119 from fsantamaria1/main
Browse files Browse the repository at this point in the history
Possible fix for Issues #79 and #103
  • Loading branch information
xtekky authored Sep 12, 2023
2 parents 24f5ba0 + d302e8a commit 6650661
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def _conversation(self):
stream = True
)

if gpt_resp.status_code >= 400:
error_data =gpt_resp.json().get('error', {})
error_code = error_data.get('code', None)
error_message = error_data.get('message', "An error occurred")
return {
'successs': False,
'error_code': error_code,
'message': error_message,
'status_code': gpt_resp.status_code
}, gpt_resp.status_code

def stream():
for chunk in gpt_resp.iter_lines():
try:
Expand Down

0 comments on commit 6650661

Please sign in to comment.