Skip to content

Commit

Permalink
refine prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyeh committed Jul 2, 2024
1 parent 8484a63 commit c1a8feb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
sql_regeneration_system_prompt = """
### TASK ###
There are two subtasks in this task.
- Given a list of user corrections, regenerate the corresponding SQL query.
- For each modified SQL query, update the corresponding SQL summary, CTE name.
- If subsequent steps are dependent on the corrected step, make sure to update the SQL query, SQL summary and CTE name in subsequent steps if needed.
- Regenerate the description after correcting all of the steps.
#### Subtask 1: SQL Query and Summary Regeneration for Each Step ####
Given each step of the SQL query, SQL summary, cte name and a list of user corrections,
your job is to regenerate the corresponding SQL query given the user corrections and regenerate the corresponding SQL summary if necessary.
### INPUT STRUCTURE ###
#### Subtask 2: Description Generation and SQL Query Regeneration considering all steps ####
Given the original description and the each step of the SQL query, SQL summary, cte name(some of the steps include regenerated SQL queries, SQL summary from the subtask1),
your job is to regenerate the description considering all steps and regenerate the SQL query considering if regenerated SQL query would affectes original SQL query in subsequent steps.
{
"description": "<original_description_string>",
"steps": [
{
"summary": "<original_sql_summary_string>",
"sql": "<original_sql_string>",
"cte_name": "<original_cte_name_string>",
"corrections": [
{
"before": {
"type": "<filter/selectItems/relation/groupByKeys/sortings>",
"value": "<original_value_string>"
},
"after": {
"type": "<sql_expression/nl_expression>",
"value": "<new_value_string>"
}
},...
]
},...
]
}
### OUTPUT STRUCTURE ###
Generate modified results according to the following in JSON format:
{
"description": "<modified_description_string>",
"steps": [
{
"summary": "<modified_sql_summary_string>",
"sql": "<modified_sql_string>",
"cte_name": "<modified_cte_name_string>",
},...
]
}
"""
53 changes: 2 additions & 51 deletions wren-ai-service/src/pipelines/sql_regeneration/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,8 @@


sql_regeneration_user_prompt_template = """
### TASK ###
- Given a list of user corrections, regenerate the corresponding SQL query.
- For each modified SQL query, update the corresponding SQL summary, CTE name.
- If subsequent steps are dependent on the corrected step, make sure to update the SQL query, SQL summary and CTE name in subsequent steps if needed.
- Regenerate the description after correcting all of the steps.
### INPUT STRUCTURE ###
{
"description": "<original_description_string>",
"steps": [
{
"summary": "<original_sql_summary_string>",
"sql": "<original_sql_string>",
"cte_name": "<original_cte_name_string>",
"corrections": [
{
"before": {
"type": "<filter/selectItems/relation/groupByKeys/sortings>",
"value": "<original_value_string>"
},
"after": {
"type": "<sql_expression/nl_expression>",
"value": "<new_value_string>"
}
},...
]
},...
]
}
### INPUT ###
{{ results }}
### OUTPUT STRUCTURE ###
Generate modified results according to the following in JSON format:
{
"description": "<modified_description_string>",
"steps": [
{
"summary": "<modified_sql_summary_string>",
"sql": "<modified_sql_string>",
"cte_name": "<modified_cte_name_string>",
},...
]
}
inputs: {{ results }}
Think step by step
"""

Expand Down

0 comments on commit c1a8feb

Please sign in to comment.