From 80135706a6e4bcc2242eacbb098d14d7bbab93dc Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Fri, 10 Jan 2025 15:31:00 +0100 Subject: [PATCH] [GPT] make incompatible model errors more clear --- Services/Services_bases/gpt_service/gpt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Services/Services_bases/gpt_service/gpt.py b/Services/Services_bases/gpt_service/gpt.py index d30192879..3972bf667 100644 --- a/Services/Services_bases/gpt_service/gpt.py +++ b/Services/Services_bases/gpt_service/gpt.py @@ -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