Skip to content

Commit

Permalink
Introduce custom exception
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschulz-COL committed Nov 10, 2023
1 parent 135a94a commit 538d176
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vizro-ai/src/vizro_ai/_vizro_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
logger = logging.getLogger(__name__)


class DebugFailure(Exception):
pass


class VizroAI:
"""Vizro-AI main class."""

Expand Down Expand Up @@ -113,12 +117,11 @@ 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(
raise DebugFailure(
"Chart creation failed. Retry debugging has reached maximum limit, fallout response is \
provided. "
provided. Try to rephrase the prompt, or try to select a different model. "
+ 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:
Expand Down

0 comments on commit 538d176

Please sign in to comment.