Skip to content

Commit

Permalink
Properly return API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
njbbaer committed May 5, 2024
1 parent 38a2f0c commit c9449c2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ async def call_api(self, messages, parameters):
url = f"{self.api_url}/v1/chat/completions"
response = await client.post(url, headers=headers, json=body)
response.raise_for_status()
return response.json()
response_json = response.json()
if "error" in response_json:
raise Exception(response_json["error"]["message"])
return response_json

0 comments on commit c9449c2

Please sign in to comment.