diff --git a/vizro-ai/docs/pages/user_guides/run_vizro_ai.md b/vizro-ai/docs/pages/user_guides/run_vizro_ai.md index 0d7874885..d488e30f0 100644 --- a/vizro-ai/docs/pages/user_guides/run_vizro_ai.md +++ b/vizro-ai/docs/pages/user_guides/run_vizro_ai.md @@ -67,11 +67,15 @@ Vizro-AI's `_get_chart_code` method returns the Python code string that can be u ```py import vizro.plotly.express as px from vizro_ai import VizroAI - + vizro_ai = VizroAI() - + df = px.data.gapminder() - code_string = vizro_ai._get_chart_code(df, "describe life expectancy per continent over time", explain=True) + output = vizro_ai._get_chart_code(df, "describe life expectancy per continent over time", explain=True) + + code_string = output.get("code_string") + code_explanation = output.get("code_explanation") + business_insights = output.get("business_insights") ``` === "code_string" [![ResultCode]][ResultCode] diff --git a/vizro-ai/src/vizro_ai/_vizro_ai.py b/vizro-ai/src/vizro_ai/_vizro_ai.py index df1130223..05e1b977d 100644 --- a/vizro-ai/src/vizro_ai/_vizro_ai.py +++ b/vizro-ai/src/vizro_ai/_vizro_ai.py @@ -91,7 +91,7 @@ def _run_plot_tasks( "code_string": code_string, } - def _get_chart_code(self, df: pd.DataFrame, user_input: str) -> str: + def _get_chart_code(self, df: pd.DataFrame, user_input: str, explain: bool = False) -> str: """Get Chart code of vizro via english descriptions, English to chart translation. Can be used in integration with other application if only code snippet return is required. @@ -99,9 +99,10 @@ def _get_chart_code(self, df: pd.DataFrame, user_input: str) -> str: Args: df: The dataframe to be analyzed user_input: User questions or descriptions of the desired visual + explain: Flag to include explanation in response """ # TODO refine and update error handling - return self._run_plot_tasks(df, user_input, explain=False).get("code_string") + return self._run_plot_tasks(df, user_input, explain=explain) def plot(self, df: pd.DataFrame, user_input: str, explain: bool = False) -> Union[None, Dict[str, Any]]: """Plot visuals using vizro via english descriptions, english to chart translation.