Skip to content

Commit 92a815e

Browse files
improving the code generation template in case of plotly
1 parent 95149a9 commit 92a815e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandasai/core/prompts/templates/generate_python_code_with_sql.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def execute_sql_query(sql_query: str) -> pd.Dataframe
1111
</function>
1212

1313
For the charts, you can either use `matplotlib.pyplot` or `plotly.express` to generate the charts.
14-
If you use `plotly.express`, you have to save each chart by using `fig.write_json` (e.g., `fig.write_json("path/to/file.json", pretty=True)`).
14+
Use `plotly.express` only if the user explicitly asks for it, otherwise use `matplotlib.pyplot`.
15+
If `plotly.express` is used, save each chart by using `fig.write_json` (e.g., `fig.write_json("path/to/file.json", pretty=True)`).
1516

1617
{% if last_code_generated != "" and context.memory.count() > 0 %}
1718
{{ last_code_generated }}

tests/unit_tests/prompts/test_sql_prompt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def execute_sql_query(sql_query: str) -> pd.Dataframe
8282
</function>
8383
8484
For the charts, you can either use `matplotlib.pyplot` or `plotly.express` to generate the charts.
85-
If you use `plotly.express`, you have to save each chart by using `fig.write_json` (e.g., `fig.write_json("path/to/file.json", pretty=True)`).
85+
Use `plotly.express` only if the user explicitly asks for it, otherwise use `matplotlib.pyplot`.
86+
If `plotly.express` is used, save each chart by using `fig.write_json` (e.g., `fig.write_json("path/to/file.json", pretty=True)`).
8687
8788
8889
Update this initial code:

0 commit comments

Comments
 (0)