diff --git a/vizro-ai/changelog.d/20231110_223949_maximilian_schulz_improve_AI_error_message.md b/vizro-ai/changelog.d/20231110_223949_maximilian_schulz_improve_AI_error_message.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-ai/changelog.d/20231110_223949_maximilian_schulz_improve_AI_error_message.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-ai/src/vizro_ai/_vizro_ai.py b/vizro-ai/src/vizro_ai/_vizro_ai.py index 622f4421f..df1130223 100644 --- a/vizro-ai/src/vizro_ai/_vizro_ai.py +++ b/vizro-ai/src/vizro_ai/_vizro_ai.py @@ -19,6 +19,10 @@ logger = logging.getLogger(__name__) +class DebugFailure(Exception): + pass + + class VizroAI: """Vizro-AI main class.""" @@ -113,12 +117,10 @@ def plot(self, df: pd.DataFrame, user_input: str, explain: bool = False) -> Unio code_explanation = output_dict.get("code_explanation") if code_string.startswith("Failed to debug code"): - logger.warning( - "Chart creation failed. Retry debugging has reached maximum limit, fallout response is \ - provided. " - + code_string + raise DebugFailure( + "Chart creation failed. Retry debugging has reached maximum limit. Try to rephrase the prompt, " + "or try to select a different model. Fallout response is provided: \n\n" + code_string ) - return if not explain: _exec_code(code=code_string, local_args={"df": df}, show_fig=True, is_notebook_env=_is_jupyter()) if explain: