From b872cf63a4621cab84674ad9f6d23d9a3ed6bbc0 Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 5 Feb 2025 18:24:34 -0700 Subject: [PATCH] feat(prompts): Enhance SQL query generation and error handling instructions - Update failed SQL fix prompt to emphasize query output format - Add clarification to dataset selector prompt about selecting multiple datasets --- .../analyst_chat_prompts/failed_to_fix_sql_prompts.rs | 6 +++++- .../prompts/generate_sql_prompts/dataset_selector_prompt.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs b/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs index 308196fe2..03df2a992 100644 --- a/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs +++ b/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs @@ -17,7 +17,9 @@ PLEASE OUTPUT THE SQL QUERY IN THE FOLLOWING FORMAT: - Keep your response under 50 words - Do not output the failed SQL query in your response - Keep this response fairly non-technical -- escape columns, datasets, tables, errors, etc. with backticks.".to_string() +- escape columns, datasets, tables, errors, etc. with backticks. +- You must output the sql query in the format specified above. +".to_string() } pub fn failed_to_fix_sql_user_prompt( @@ -49,5 +51,7 @@ pub fn failed_to_fix_sql_user_prompt( message.push_str(error); } + message.push_str("\n\nPlease output the SQL query in the format specified above. (```sql ... ```)"); + message } diff --git a/api/src/utils/prompts/generate_sql_prompts/dataset_selector_prompt.rs b/api/src/utils/prompts/generate_sql_prompts/dataset_selector_prompt.rs index 656249d72..a23c5a847 100644 --- a/api/src/utils/prompts/generate_sql_prompts/dataset_selector_prompt.rs +++ b/api/src/utils/prompts/generate_sql_prompts/dataset_selector_prompt.rs @@ -13,6 +13,7 @@ Your task is to pick all the datasets required to answer the user question/reque - Feel free to select multiple datasets that can be joined together to provide more complete answers - If the user requests advanced analysis like predictions, forecasts, correlation, impact analysis, etc., identify all datasets that could be combined for the analysis - Consider relationships between datasets and how they can be joined to provide comprehensive answers +- Multiple dataset can be selected even while one completely answers the user request. "#, datasets )