Hey,
I was playing around with PandasAI and am facing a caching problem:
When I’m using the following code (what is just a code copy from here and here:
from dash import Dash, html, dcc, callback, Output, Input
import plotly.express as px
import pandas as pd
from pandasai.llm import OpenAI
llm = OpenAI(api_token="put-in-your-api-token-here")
import seaborn as sns
from pandasai import SmartDataframe
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv')
app = Dash(__name__)
app.layout = html.Div([
html.H1(children='Title of Dash App', style={'textAlign':'center'}),
dcc.Dropdown(df.country.unique(), 'Canada', id='dropdown-selection'),
dcc.Graph(id='graph-content')
])
data = sns.load_dataset('titanic')
df = SmartDataframe(data, config={'llm': llm})
response = df.chat("""Return the survived class in percentage""")
print(response)
@callback(
Output('graph-content', 'figure'),
Input('dropdown-selection', 'value')
)
def update_graph(value):
dff = df[df.country==value]
return px.line(dff, x='year', y='pop')
if __name__ == '__main__':
app.run(debug=True)
The Dash app is crashing because of a caching error:
duckdb.duckdb.IOException: IO Error: Could not set lock on file "/Users/.../dash_app/cache/cache_db_0.9.db": Conflicting lock is held in /Library/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python (PID 31194) by user .... See also https://duckdb.org/docs/connect/concurrency
Well, I tried already to downgrade Dash, PandasAI or even DuckDB, but found no solution.
Maybe you have a better idea to solve that?
Thank you again and have a nice weekend