Skip to content

Commit

Permalink
Merge pull request #520 from zyclove/ai-sql-optimize
Browse files Browse the repository at this point in the history
feat: add  Validate the syntax of the output SQL to ensure it is correct and executable.
  • Loading branch information
zainhoda authored Jul 25, 2024
2 parents 0880e46 + 759b14d commit b7604e2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vanna/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ def get_sql_prompt(
"3. If the provided context is insufficient, please explain why it can't be generated. \n"
"4. Please use the most relevant table(s). \n"
"5. If the question has been asked and answered before, please repeat the answer exactly as it was given before. \n"
f"6. Ensure that the output SQL is {self.dialect}-compliant and executable, and free of syntax errors. \n"
)

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

except Exception as e:
raise e

self.run_sql_is_set = True
self.run_sql = run_sql_clickhouse

Expand Down

0 comments on commit b7604e2

Please sign in to comment.