From 01531cb16d09b9290fc091434b0c69cb91a8f500 Mon Sep 17 00:00:00 2001 From: Hans van Dam Date: Sat, 13 May 2023 05:03:37 +0200 Subject: [PATCH] remove quotes from sql database prompts (caused syntax error) (#4101) fixes a syntax error mentioned in #2027 and #3305 another PR to remedy is in #3385, but I believe that is not tacking the core problem. Also #2027 mentions a solution that works: add to the prompt: 'The SQL query should be outputted plainly, do not surround it in quotes or anything else.' To me it seems strange to first ask for: SQLQuery: "SQL Query to run" and then to tell the LLM not to put the quotes around it. Other templates (than the sql one) do not use quotes in their steps. This PR changes that to: SQLQuery: SQL Query to run --- langchain/chains/sql_database/prompt.py | 72 ++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/langchain/chains/sql_database/prompt.py b/langchain/chains/sql_database/prompt.py index 83acefc48e7..a2b6f4c28e5 100644 --- a/langchain/chains/sql_database/prompt.py +++ b/langchain/chains/sql_database/prompt.py @@ -11,10 +11,10 @@ Pay attention to use only the column names that you can see in the schema descri Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the tables listed below. @@ -48,10 +48,10 @@ Pay attention to use today() function to get the current date, if the question i Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -71,10 +71,10 @@ Pay attention to use CURRENT_DATE() function to get the current date, if the que Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -95,10 +95,10 @@ Pay attention to use CAST(GETDATE() as date) function to get the current date, i Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -118,10 +118,10 @@ Pay attention to use CURDATE() function to get the current date, if the question Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -142,10 +142,10 @@ Pay attention to use CURDATE() function to get the current date, if the question Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -166,10 +166,10 @@ Pay attention to use TRUNC(SYSDATE) function to get the current date, if the que Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -190,10 +190,10 @@ Pay attention to use CURRENT_DATE function to get the current date, if the quest Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info} @@ -213,10 +213,10 @@ Pay attention to use date('now') function to get the current date, if the questi Use the following format: -Question: "Question here" -SQLQuery: "SQL Query to run" -SQLResult: "Result of the SQLQuery" -Answer: "Final answer here" +Question: Question here +SQLQuery: SQL Query to run +SQLResult: Result of the SQLQuery +Answer: Final answer here Only use the following tables: {table_info}