Mentioned the idea here initially:
https://github.com/hwchase17/langchain/pull/2106#issuecomment-1487509106
Since there have been dialect-specific issues, we should use
dialect-specific prompts. This way, each prompt can be separately
modified to best suit each dialect as needed. This adds a prompt for
each dialect supported in sqlalchemy (mssql, mysql, mariadb, postgres,
oracle, sqlite). For this initial implementation, the only differencse
between the prompts is the instruction for the clause to use to limit
the number of rows queried for, and the instruction for wrapping column
names using each dialect's identifier quote character.
_DEFAULT_TEMPLATE="""Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.
_DEFAULT_TEMPLATE="""Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.
_mssql_prompt="""You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.
_mysql_prompt="""You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.
_mariadb_prompt="""You are a MariaDB expert. Given an input question, first create a syntactically correct MariaDB query to run, then look at the results of the query and return the answer to the input question.
_oracle_prompt="""You are an Oracle SQL expert. Given an input question, first create a syntactically correct Oracle SQL query to run, then look at the results of the query and return the answer to the input question.
Neverqueryforallcolumnsfromatable.Youmustqueryonlythecolumnsthatareneededtoanswerthequestion.Wrapeachcolumnnameindoublequotes(") to denote them as delimited identifiers.
_postgres_prompt="""You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.
Neverqueryforallcolumnsfromatable.Youmustqueryonlythecolumnsthatareneededtoanswerthequestion.Wrapeachcolumnnameindoublequotes(") to denote them as delimited identifiers.
_sqlite_prompt="""You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.
Neverqueryforallcolumnsfromatable.Youmustqueryonlythecolumnsthatareneededtoanswerthequestion.Wrapeachcolumnnameindoublequotes(") to denote them as delimited identifiers.