{"version":3,"file":"sql_db_prompt.cjs","names":["PromptTemplate"],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"sourcesContent":["import { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\n\nexport const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  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.\n\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\n\nPay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `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.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `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.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `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.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\\`) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `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.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\nAlways use a schema name when executing a query.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n  template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n  inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport type SqlDialect =\n  | \"oracle\"\n  | \"postgres\"\n  | \"sqlite\"\n  | \"mysql\"\n  | \"mssql\"\n  | \"sap hana\";\n\nexport const SQL_PROMPTS_MAP: Record<SqlDialect, BasePromptTemplate> = {\n  oracle: SQL_ORACLE_PROMPT,\n  postgres: SQL_POSTGRES_PROMPT,\n  sqlite: SQL_SQLITE_PROMPT,\n  mysql: SQL_MYSQL_PROMPT,\n  mssql: SQL_MSSQL_PROMPT,\n  \"sap hana\": SQL_SAP_HANA_PROMPT,\n};\n"],"mappings":";;;AAEA,MAAa,8CAA4C,IAAIA,wBAAAA,eAAe;CAC1E,UAAU;;;;;;;;;;;;;;;;;;CAkBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,sCAAoC,IAAIA,wBAAAA,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,oCAAkC,IAAIA,wBAAAA,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,mCAAiC,IAAIA,wBAAAA,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,mCAAiC,IAAIA,wBAAAA,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,sCAAoC,IAAIA,wBAAAA,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;;CAiBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAEF,MAAa,oCAAkC,IAAIA,wBAAAA,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;EAAQ;CAC5D,CAAC;AAUF,MAAa,kBAA0D;CACrE,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,OAAO;CACP,OAAO;CACP,YAAY;CACb"}