Skip to content

Commit 0e12f38

Browse files
committed
improve prompt to always display result format
1 parent 4e33c30 commit 0e12f38

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎pandasai/core/prompts/templates/generate_python_code_with_sql.tmpl‎

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

1313
{% if last_code_generated and context.memory.count() > 0 %}
14+
Last code generated:
1415
{{ last_code_generated }}
1516
{% else %}
1617
Update this initial code:
@@ -26,7 +27,8 @@ import pandas as pd
2627
{% include 'shared/vectordb_docs.tmpl' with context %}
2728
{{ context.memory.get_last_message() }}
2829

29-
At the end, declare "result" variable as a dictionary of type and value.
30+
At the end, declare "result" variable as a dictionary of type and value in the following format:
31+
{% include 'shared/output_type_template.tmpl' with context %}
3032

3133

3234
Generate python code and return full updated code:

‎tests/unit_tests/prompts/test_sql_prompt.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def execute_sql_query(sql_query: str) -> pd.Dataframe
9494
9595
9696
97-
At the end, declare "result" variable as a dictionary of type and value.
97+
At the end, declare "result" variable as a dictionary of type and value in the following format:
98+
99+
{output_type_template}
100+
98101
99102
100103
Generate python code and return full updated code:

0 commit comments

Comments
 (0)