Handling charts in different contexts #277
jonbiemond
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
Another recent issue (#281) where |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @jonbiemond ! Is there currently a way to not have PandasAI block the code execution when using PandasAI through FastAPI when generating graphs? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are a lot of issues and discussions surrounding charts, I'd like to consolidate the discussion here.
The underlying issue
As I see it there are two closely related underlying issues, 1) the generated code does not always include a call to
plt.show()
making it hard for PandasAI to take plot-based behaviour, 2) users do not always want to have the charts displayed, specifically when using PandasAI as an API.Charts with PandasAI-as-an-API (#264, #166, #271)
When PandasAI is used as part of an app, it can be difficult for developers to capture the generated charts to pass to their apps. Currently it is possible to set
save_charts=True
and collect the chart from the output folder, however this isn't very elegant. Thestreamlit
middleware handles this neatly (#257) by replacing the call toplt.show()
with an expression that outputs the chart tostreamlit
.My concern is that it may not be very sustainable to create one-off solutions for every front-end request. Alternatively we could add a feature that returns the plot as an object instead of displaying it, this allows the developer to process the object as they see fit.
Identifying plots in code (#205)
Currently PandasAI knows there are plots in the code by looking for calls to
plt.show()
. However the generated code does not consistently includeplt.show()
when creating plots. I think we will want to come up with a more reliable way to identify plots in the generated code.Related:
Beta Was this translation helpful? Give feedback.
All reactions