Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyword explain to private vizro-ai method #256

Merged
merged 11 commits into from
Jan 9, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Removed

- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->

<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->

### Fixed

- Remove the keyword `explain` from docs example explaining the `_get_chart_code` function ([#256](https://github.com/mckinsey/vizro/pull/256))

<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
3 changes: 2 additions & 1 deletion vizro-ai/docs/pages/user_guides/run_vizro_ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ Vizro-AI's `_get_chart_code` method returns the Python code string that can be u
vizro_ai = VizroAI()

df = px.data.gapminder()
code_string = vizro_ai._get_chart_code(df, "describe life expectancy per continent over time", explain=True)
code_string = vizro_ai._get_chart_code(df, "describe life expectancy per continent over time")
```
=== "code_string"
[![ResultCode]][ResultCode]

[ResultCode]: ../../assets/user_guides/code_string_app_integration.png

The returned `code_string` can be used to dynamically render charts within your application. You may have the option to encapsulate the chart within a `fig` object or convert the figure into a JSON string for further integration.
In case you would like to use the insights or code explanation, you can use `vizro_ai._run_plot_tasks(df, ..., explain=False)`, which returns a dictionary containing the code explanation and chart insights alongside the code.
maxschulz-COL marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions vizro-ai/src/vizro_ai/_vizro_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ 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")
Expand Down
Loading