Skip to content

Commit 22c3933

Browse files
authored
chore(wren-ai-service): improve text2sql stability (#1841)
1 parent 54f5d4d commit 22c3933

File tree

1 file changed

+5
-4
lines changed
  • wren-ai-service/src/pipelines/generation/utils

1 file changed

+5
-4
lines changed

wren-ai-service/src/pipelines/generation/utils/sql.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ async def _classify_generation_result(
195195
10. Do not include ```markdown or ``` in the answer.
196196
11. A table name in the reasoning plan must be in this format: `table: <table_name>`.
197197
12. A column name in the reasoning plan must be in this format: `column: <table_name>.<column_name>`.
198+
13. ALWAYS SHOWING the last step stating that the SQL query should be generated step by step strictly based on the reasoning plan.
198199
199200
### FINAL ANSWER FORMAT ###
200201
The final answer must be a reasoning plan in plain Markdown string format
@@ -259,10 +260,10 @@ async def _classify_generation_result(
259260
260261
### GENERAL RULES ###
261262
262-
1. If USER INSTRUCTIONS is provided, please follow the instructions strictly to generate the SQL query.
263-
2. If SQL FUNCTIONS is provided, please choose the appropriate functions from the list and use it in the SQL query.
264-
3. If SQL SAMPLES is provided, please refer to the samples and learn the usage of the schema structures and how SQL is written based on them.
265-
4. If REASONING PLAN is provided, please follow the plan step by step strictly to generate the SQL query.
263+
1. YOU MUST FOLLOW the instructions strictly to generate the SQL query if the section of USER INSTRUCTIONS is available in user's input.
264+
2. YOU MUST CHOOSE the appropriate functions from the sql functionslist and use them in the SQL query if the section of SQL FUNCTIONS is available in user's input.
265+
3. YOU MUST REFER to the sql samples and learn the usage of the schema structures and how SQL is written based on them if the section of SQL SAMPLES is available in user's input.
266+
4. YOU MUST FOLLOW the reasoning plan step by step strictly to generate the SQL query if the section of REASONING PLAN is available in user's input.
266267
267268
{TEXT_TO_SQL_RULES}
268269

0 commit comments

Comments
 (0)