From f3e4cabf079975e632a93fe122da7bcd4dad12b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:21:43 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../user-guides/add-generated-chart-usecase.md | 13 ++++++------- .../pages/user-guides/customize-vizro-ai.md | 1 - .../user-guides/vizro-ai-langchain-guide.md | 18 ++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/vizro-ai/docs/pages/user-guides/add-generated-chart-usecase.md b/vizro-ai/docs/pages/user-guides/add-generated-chart-usecase.md index 829c4e1f8..60eb24100 100644 --- a/vizro-ai/docs/pages/user-guides/add-generated-chart-usecase.md +++ b/vizro-ai/docs/pages/user-guides/add-generated-chart-usecase.md @@ -10,18 +10,17 @@ This guide explains the different ways in which you can add a chart generated by !!! example "Vizro-AI chart" === "Code for the cell" - ```python import vizro_ai from vizro_ai import VizroAI import vizro.plotly.express as px from dotenv import load_dotenv - + load_dotenv() - + df = px.data.gapminder() vizro_ai = VizroAI(model="gpt-4o") - + result = vizro_ai.plot( df, """Plot a bubble chart to show the changes in life expectancy @@ -30,8 +29,8 @@ This guide explains the different ways in which you can add a chart generated by Add animation on yearly basis, and do not use facets. Put the legend on top""", return_elements=True, - ) - + ) + print(f"Insight:\n{result.chart_insights}\n") print(f"Code explanation:\n{result.code_explanation}\n\nCode:\n{result.code_vizro}\n") result.get_fig_object(df).show() @@ -40,7 +39,7 @@ This guide explains the different ways in which you can add a chart generated by === "Result" [![VizroAIChart]][vizroaichart] -2. Insert the resulting chart into a dashboard. +1. Insert the resulting chart into a dashboard. Once you are satisfied with the chart, you can add it to a [Vizro](https://github.com/mckinsey/vizro/tree/main/vizro-core) dashboard. diff --git a/vizro-ai/docs/pages/user-guides/customize-vizro-ai.md b/vizro-ai/docs/pages/user-guides/customize-vizro-ai.md index 44ed549db..03f35cbe5 100644 --- a/vizro-ai/docs/pages/user-guides/customize-vizro-ai.md +++ b/vizro-ai/docs/pages/user-guides/customize-vizro-ai.md @@ -18,7 +18,6 @@ vizro_ai = VizroAI(model="") For the string settings to work, you must supply your API key via environment variables. The relevant variable names to be set are noted in each vendor tab. === "OpenAI" - | Environment variable | Name(s) | | -------------------- | ----------------- | | API key | `OPENAI_API_KEY` | diff --git a/vizro-ai/docs/pages/user-guides/vizro-ai-langchain-guide.md b/vizro-ai/docs/pages/user-guides/vizro-ai-langchain-guide.md index f5789d537..b43653356 100644 --- a/vizro-ai/docs/pages/user-guides/vizro-ai-langchain-guide.md +++ b/vizro-ai/docs/pages/user-guides/vizro-ai-langchain-guide.md @@ -115,9 +115,7 @@ chain = llm_with_tools | inject_df | tool_router.map() Now you can use the chain to generate charts or dashboards based on natural language queries. The chain will generate code that you can use to create visualizations. - !!! example "Generate chart code" - === "Code" ```python # Load sample data @@ -126,17 +124,17 @@ Now you can use the chain to generate charts or dashboards based on natural lang plot_response = chain.invoke("Plot GDP per capita for each continent") print(plot_response[0].content) ``` + === "Vizro-AI Generated Code" ```python import plotly.graph_objects as go from vizro.models.types import capture + @capture("graph") def custom_chart(data_frame): continent_gdp = data_frame.groupby("continent")["gdpPercap"].mean().reset_index() - fig = go.Figure( - data=[go.Bar(x=continent_gdp["continent"], y=continent_gdp["gdpPercap"])] - ) + fig = go.Figure(data=[go.Bar(x=continent_gdp["continent"], y=continent_gdp["gdpPercap"])]) fig.update_layout( title="GDP per Capita by Continent", xaxis_title="Continent", @@ -146,14 +144,16 @@ Now you can use the chain to generate charts or dashboards based on natural lang ``` !!! example "Generate dashboard code" - === "Code" ```python dfs = [px.data.gapminder()] - dashboard_response = chain.invoke("Create a dashboard. This dashboard has a chart showing the correlation between gdpPercap and lifeExp.") + dashboard_response = chain.invoke( + "Create a dashboard. This dashboard has a chart showing the correlation between gdpPercap and lifeExp." + ) print(dashboard_response[0].content) ``` + === "Vizro-AI Generated Code" ```python ############ Imports ############## @@ -166,9 +166,7 @@ Now you can use the chain to generate charts or dashboards based on natural lang @capture("graph") def gdp_life_exp_graph(data_frame): fig = go.Figure() - fig.add_trace( - go.Scatter(x=data_frame["gdpPercap"], y=data_frame["lifeExp"], mode="markers") - ) + fig.add_trace(go.Scatter(x=data_frame["gdpPercap"], y=data_frame["lifeExp"], mode="markers")) fig.update_layout( title="GDP per Capita vs Life Expectancy", xaxis_title="GDP per Capita",