Skip to content

Commit

Permalink
[GPT] make incompatible model errors more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Jan 10, 2025
1 parent 6576ae7 commit 8013570
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Services/Services_bases/gpt_service/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ async def _get_signal_from_gpt(
openai.BadRequestError, # error in request
openai.UnprocessableEntityError # error in model (ex: model not found)
)as err:
raise errors.InvalidRequestError(
f"Error when running request with model {model} (invalid request): {err}"
) from err
if "does not support 'system' with this model" in str(err):
desc = err.body.get("message", str(err))
err_message = f"The \"{model}\" model can't be used for this request: {desc}"
else:
err_message = f"Error when running request with model {model} (invalid request): {err}"
raise errors.InvalidRequestError(err_message) from err
except openai.AuthenticationError as err:
self.logger.error(f"Invalid OpenAI api key: {err}")
self.creation_error_message = err
Expand Down

0 comments on commit 8013570

Please sign in to comment.