diff --git a/querybook/server/lib/ai_assistant/prompts/sql_complete_prompt.py b/querybook/server/lib/ai_assistant/prompts/sql_complete_prompt.py index 5a251a33c..f5dc31735 100644 --- a/querybook/server/lib/ai_assistant/prompts/sql_complete_prompt.py +++ b/querybook/server/lib/ai_assistant/prompts/sql_complete_prompt.py @@ -1,29 +1,29 @@ from langchain.prompts import PromptTemplate -prompt_template = """You are an expert in the {dialect} SQL dialect, skilled in providing precise SQL code completions. -Your task is to complete the SQL query based on the given context. - - - -===Table Schemas -{table_schemas} - -===Response Guidelines: -1. Analyze the partial query and table schemas to understand the context and determine the query's goal. -2. Identify the relevant tables and columns necessary for the query. -3. Replace with appropriate SQL code, or leave it empty if no completion is needed. +prompt_template = """You are an expert in the {dialect} SQL dialect, skilled in providing precise SQL code completions. +Your task is to complete the SQL query based on the given context. + + + +===Table Schemas +{table_schemas} + +===Response Guidelines: +1. Analyze the partial query and table schemas to understand the context and determine the query's goal. +2. Identify the relevant tables and columns necessary for the query. +3. Replace with appropriate SQL code, or leave it empty if no completion is needed. 4. Make sure the completion does not overlap with the prefix or suffix. 5. Respond in JSON format - -===Response Format: -{{ + +===Response Format: +{{ "completion": "the SQL code to replace , if any" -}} +}} ===Example Input: -sele from some_table +sele from some_table Reasoning: The prefix "sele" suggests that the query is likely a SELECT statement. The table schemas indicate the available columns. The completion should be a list of columns to select from the table "some_table". @@ -35,8 +35,7 @@ }} ===Input -{prefix}{suffix} - +{prefix}{suffix} """