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

Flask: chart still generated if chart=False #355

Open
Molrn opened this issue Apr 11, 2024 · 0 comments
Open

Flask: chart still generated if chart=False #355

Molrn opened this issue Apr 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Molrn
Copy link
Contributor

Molrn commented Apr 11, 2024

Describe the bug
When the option chart and redraw_chart are set to false, the function generate_plotly_code of the model is still executed. If the dataset is big, the execution takes a lot of time, so it can be very problematic for users who do not need this step.

To Reproduce

import vanna
from vanna.remote import VannaDefault
from vanna.flask import VannaFlaskApp

class MyModel(VannaDefault):
    def generate_plotly_code(
        self, question: str = None, sql: str = None, df_metadata: str = None, **kwargs
    ) -> str:
        plotly_code = super().generate_plotly_code(question, sql, df_metadata, **kwargs)
        self.log(plotly_code)
        return plotly_code


vn = MyModel(model='chinook', api_key=vanna.get_api_key('my-email@example.com'))
vn.connect_to_sqlite('https://vanna.ai/Chinook.sqlite')

app = VannaFlaskApp(vn, chart=False, redraw_chart=False)
app.run()

Execute this code to run the app, then ask a question in the app. No graph is generated:
image

But this appears in the logs:

Your app is running at:
http://localhost:8084
 * Serving Flask app 'vanna.flask'
 * Debug mode: off
import plotly.express as px

if len(df) == 1:
    fig = px.indicators.generic.Indicator(
        value=df['TotalSales'][0],
        title=df['Name'][0]
    )
else:
    fig = px.bar(df, x='Name', y='TotalSales', title='Top 10 Artists by Sales')

Expected Behavior
The function should not be executed. It comes as an important problem when the dataset is large or the LLM access is limited, because the function sends all the dataset to the LLM.

Desktop

  • OS: [Ubuntu]
  • Version: [22.04]
  • Python: [3.10]
  • Vanna: [0.3.3]
@Molrn Molrn added the bug Something isn't working label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant