Skip to content

Commit b7604e2

Browse files
authored
Merge pull request #520 from zyclove/ai-sql-optimize
feat: add Validate the syntax of the output SQL to ensure it is correct and executable.
2 parents 0880e46 + 759b14d commit b7604e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/vanna/base/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ def get_sql_prompt(
577577
"3. If the provided context is insufficient, please explain why it can't be generated. \n"
578578
"4. Please use the most relevant table(s). \n"
579579
"5. If the question has been asked and answered before, please repeat the answer exactly as it was given before. \n"
580+
f"6. Ensure that the output SQL is {self.dialect}-compliant and executable, and free of syntax errors. \n"
580581
)
581582

582583
message_log = [self.system_message(initial_prompt)]
@@ -1087,7 +1088,7 @@ def run_sql_clickhouse(sql: str) -> Union[pd.DataFrame, None]:
10871088

10881089
except Exception as e:
10891090
raise e
1090-
1091+
10911092
self.run_sql_is_set = True
10921093
self.run_sql = run_sql_clickhouse
10931094

0 commit comments

Comments
 (0)