From 2b87da51ede669d2c57947e418513ec36902d607 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Tue, 18 Jul 2023 17:46:11 -0300 Subject: [PATCH] feat: Implements i18n(pt-BR) for prompts in SQLDatabaseChain --- .../chains/sql/database/prompt/Prompt.java | 138 ++---------------- .../langchain/utils/ResourceBundleUtils.java | 56 +++++++ .../resources/i18n/messages_en_US.properties | 80 ++++++++++ .../resources/i18n/messages_pt_BR.properties | 84 +++++++++++ 4 files changed, 230 insertions(+), 128 deletions(-) create mode 100644 langchain-core/src/main/java/com/hw/langchain/utils/ResourceBundleUtils.java create mode 100644 langchain-core/src/main/resources/i18n/messages_en_US.properties create mode 100644 langchain-core/src/main/resources/i18n/messages_pt_BR.properties diff --git a/langchain-core/src/main/java/com/hw/langchain/chains/sql/database/prompt/Prompt.java b/langchain-core/src/main/java/com/hw/langchain/chains/sql/database/prompt/Prompt.java index b6ee4c439..e74a4db94 100644 --- a/langchain-core/src/main/java/com/hw/langchain/chains/sql/database/prompt/Prompt.java +++ b/langchain-core/src/main/java/com/hw/langchain/chains/sql/database/prompt/Prompt.java @@ -20,6 +20,7 @@ import com.hw.langchain.output.parsers.list.CommaSeparatedListOutputParser; import com.hw.langchain.prompts.prompt.PromptTemplate; +import com.hw.langchain.utils.ResourceBundleUtils; import java.util.List; import java.util.Map; @@ -30,164 +31,45 @@ */ public class Prompt { - private static String PROMPT_SUFFIX = """ - Only use the following tables: - {table_info} + private static String PROMPT_SUFFIX = ResourceBundleUtils.getString("prompt.suffix"); - Question: {input} - """; - - private static String _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. - - Never query for all the columns from a specific table, only ask for a the few relevant columns given the question. - - Pay 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. - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _DEFAULT_TEMPLATE = ResourceBundleUtils.getString("prompt.default.template"); public static PromptTemplate PROMPT = new PromptTemplate(List.of("input", "table_info", "dialect", "top_k"), _DEFAULT_TEMPLATE + PROMPT_SUFFIX); - private static String _DECIDER_TEMPLATE = - """ - Given the below input question and list of potential tables, output a comma separated list of the table names that may be necessary to answer this question. - - Question: {query} - - Table Names: {table_names} - - Relevant Table Names: - """; + private static String _DECIDER_TEMPLATE = ResourceBundleUtils.getString("prompt.decider.template"); public static PromptTemplate DECIDER_PROMPT = new PromptTemplate(_DECIDER_TEMPLATE, List.of("query", "table_names"), new CommaSeparatedListOutputParser()); - private static String _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. - Unless 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. - Never 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. - Pay 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. - Pay attention to use CURDATE() function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _mysql_prompt = ResourceBundleUtils.getString("prompt.database.mysql"); public static PromptTemplate MYSQL_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _mysql_prompt + PROMPT_SUFFIX); - private static String _h2_prompt = - """ - You are a H2 expert. Given an input question, first create a syntactically correct H2 query to run, then look at the results of the query and return the answer to the input question. - Unless 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 H2. You can order the results to return the most informative data in the database. - Never 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. - Pay 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. - Pay attention to use CURDATE() function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _h2_prompt = ResourceBundleUtils.getString("prompt.database.h2");; public static PromptTemplate H2_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _h2_prompt + PROMPT_SUFFIX); - private static String _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. - Unless 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 MariaDB. You can order the results to return the most informative data in the database. - Never 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. - Pay 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. - Pay attention to use CURDATE() function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _mariadb_prompt = ResourceBundleUtils.getString("prompt.database.mariadb");; public static PromptTemplate MARIADB_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _mariadb_prompt + PROMPT_SUFFIX); - private static String _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. - Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the FETCH FIRST n ROWS ONLY clause as per Oracle SQL. You can order the results to return the most informative data in the database. - Never 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. - Pay 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. - Pay attention to use TRUNC(SYSDATE) function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _oracle_prompt = ResourceBundleUtils.getString("prompt.database.oracle"); public static PromptTemplate ORACLE_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _oracle_prompt + PROMPT_SUFFIX); - private static String _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. - Unless 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. - Never 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. - Pay 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. - Pay attention to use CURRENT_DATE function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _postgres_prompt = ResourceBundleUtils.getString("prompt.database.postgres"); public static PromptTemplate POSTGRES_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _postgres_prompt + PROMPT_SUFFIX); - private static String _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. - Unless 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. - Never 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. - Pay 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. - Pay attention to use date('now') function to get the current date, if the question involves "today". - - Use the following format: - - Question: Question here - SQLQuery: SQL Query to run - SQLResult: Result of the SQLQuery - Answer: Final answer here - - """; + private static String _sqlite_prompt = ResourceBundleUtils.getString("prompt.database.sqlite"); public static PromptTemplate SQLITE_PROMPT = new PromptTemplate(List.of("input", "table_info", "top_k"), _sqlite_prompt + PROMPT_SUFFIX); diff --git a/langchain-core/src/main/java/com/hw/langchain/utils/ResourceBundleUtils.java b/langchain-core/src/main/java/com/hw/langchain/utils/ResourceBundleUtils.java new file mode 100644 index 000000000..2302c9031 --- /dev/null +++ b/langchain-core/src/main/java/com/hw/langchain/utils/ResourceBundleUtils.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hw.langchain.utils; + +import org.apache.commons.lang3.LocaleUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import lombok.experimental.UtilityClass; + +import java.util.Locale; +import java.util.ResourceBundle; + +@UtilityClass +public class ResourceBundleUtils { + + private static final Logger LOG = LoggerFactory.getLogger(ResourceBundleUtils.class); + + private static final String BUNDLE_NAME = "i18n.messages"; + private static final String USE_LANGUAGE_ENV = "USE_LANGUAGE"; + + public static String getString(String key) { + String language = System.getenv(USE_LANGUAGE_ENV); + + Locale locale = new Locale("en", "US"); + + if (language != null) { + try { + locale = LocaleUtils.toLocale(language); + LOG.info("Using locale from {}", language); + } catch (Exception ex) { + LOG.warn("Can't load locale for language {}, setting default en_US", language); + } + } + + ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, locale); + return bundle.getString(key); + } + +} diff --git a/langchain-core/src/main/resources/i18n/messages_en_US.properties b/langchain-core/src/main/resources/i18n/messages_en_US.properties new file mode 100644 index 000000000..12282a996 --- /dev/null +++ b/langchain-core/src/main/resources/i18n/messages_en_US.properties @@ -0,0 +1,80 @@ +prompt.suffix=Only use the following tables: {table_info} Question: {input} +prompt.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. \n \ +Never query for all the columns from a specific table, only ask for a the few relevant columns given the question. \n \ +Pay 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 \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here +prompt.decider.template=Given the below input question and list of potential tables, output a comma separated list of the table names that may be necessary to answer this question.\ +Question: {query} \n \ +Table Names: {table_names} \n \ +Relevant Table Names: + +prompt.database.mysql=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. \n \ +Unless 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. \n \ +Never 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. \n \ +Pay 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 \ +Pay attention to use CURDATE() function to get the current date, if the question involves "today". \n \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here + +prompt.database.h2=You are a H2 expert. Given an input question, first create a syntactically correct H2 query to run, then look at the results of the query and return the answer to the input question. \n \ +Unless 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 H2. You can order the results to return the most informative data in the database. \n \ +Never 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. \n \ +Pay 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 \ +Pay attention to use CURDATE() function to get the current date, if the question involves "today". \n \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here + +prompt.database.mariadb=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. \n \ +Unless 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 MariaDB. You can order the results to return the most informative data in the database. \n \ +Never 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. \n \ +Pay 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 \ +Pay attention to use CURDATE() function to get the current date, if the question involves "today". \n \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here + +prompt.database.oracle=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. \n \ +Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the FETCH FIRST n ROWS ONLY clause as per Oracle SQL. You can order the results to return the most informative data in the database. \n \ +Never 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. \n \ +Pay 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 \ +Pay attention to use TRUNC(SYSDATE) function to get the current date, if the question involves "today". \n \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here + +prompt.database.postgres=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. \n \ +Unless 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.\ +Never 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.\ +Pay 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.\ +Pay attention to use CURRENT_DATE function to get the current date, if the question involves "today".\ +Use the following format:\ +Question: Question here\ +SQLQuery: SQL Query to run\ +SQLResult: Result of the SQLQuery\ +Answer: Final answer here + +prompt.database.sqlite=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. \n \ +Unless 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. \n \ +Never 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. \n \ +Pay 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 \ +Pay attention to use date('now') function to get the current date, if the question involves "today". \n \ +Use the following format: \n \ +Question: Question here \n \ +SQLQuery: SQL Query to run \n \ +SQLResult: Result of the SQLQuery \n \ +Answer: Final answer here + diff --git a/langchain-core/src/main/resources/i18n/messages_pt_BR.properties b/langchain-core/src/main/resources/i18n/messages_pt_BR.properties new file mode 100644 index 000000000..4c926f8ca --- /dev/null +++ b/langchain-core/src/main/resources/i18n/messages_pt_BR.properties @@ -0,0 +1,84 @@ +prompt.suffix=Use somente as seguintes tabelas: \n \ + {table_info} \n \ + Pergunta: {input} \n +prompt.default.template=Dada uma pergunta de entrada, primeiro crie uma consulta de {dialect} sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta. A menos que o usu�rio especifique em sua pergunta um n�mero espec�fico de exemplos que deseja obter, sempre limite sua consulta a no m�ximo {top_k} resultados. Voc� pode ordenar os resultados por uma coluna relevante para retornar os exemplos mais interessantes do banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela espec�fica, pe�a apenas algumas colunas relevantes para a pergunta. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver na descri��o do esquema. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n + +prompt.decider.template=Dada a pergunta de entrada abaixo e a lista de tabelas poss�veis, imprima uma lista separada por v�rgulas dos nomes das tabelas que podem ser necess�rios para responder a essa pergunta.\n \ +Pergunta: {consulta} \n \ +Nomes de tabelas: {table_names} \n \ +Nomes de tabelas relevantes: \n + +prompt.database.mysql=Voc� � um especialista em MySQL. Dada uma pergunta de entrada, primeiro crie uma consulta MySQL sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula LIMIT de acordo com o MySQL. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Envolva cada nome de coluna em acentos graves (`) para denot�-los como identificadores delimitados. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Preste aten��o ao usar a fun��o CURDATE() para obter a data atual, se a pergunta envolver "hoje". \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n + +prompt.database.h2=Voc� � um especialista em H2. Dada uma pergunta de entrada, primeiro crie uma consulta H2 sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula LIMIT conforme H2. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Envolva cada nome de coluna em acentos graves (`) para denot�-los como identificadores delimitados. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Preste aten��o ao usar a fun��o CURDATE() para obter a data atual, se a pergunta envolver "hoje". \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n + +prompt.database.mariadb=Voc� � um especialista em MariaDB. Dada uma pergunta de entrada, primeiro crie uma consulta MariaDB sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula LIMIT conforme MariaDB. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Envolva cada nome de coluna em acentos graves (`) para denot�-los como identificadores delimitados. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Preste aten��o ao usar a fun��o CURDATE() para obter a data atual, se a pergunta envolver "hoje". \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n + +prompt.database.oracle=Voc� � um especialista em Oracle SQL. Dada uma pergunta de entrada, primeiro crie uma consulta Oracle SQL sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula FETCH FIRST n ROWS ONLY de acordo com o Oracle SQL. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Coloque cada nome de coluna entre aspas duplas (") para denot�-los como identificadores delimitados. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Preste aten��o ao usar a fun��o TRUNC(SYSDATE) para obter a data atual, se a pergunta envolver "hoje". \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n + +prompt.database.postgres=Voc� � um especialista em PostgreSQL. Dada uma pergunta de entrada, primeiro crie uma consulta PostgreSQL sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula LIMIT de acordo com o PostgreSQL. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados.\n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Coloque cada nome de coluna entre aspas duplas (") para denot�-los como identificadores delimitados.\n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela.\n \ +Preste aten��o ao usar a fun��o CURRENT_DATE para obter a data atual, se a pergunta envolver "hoje".\n \ + \n \ +Use o seguinte formato:\n \ + \n \ +Pergunta: Pergunta aqui\n \ +SQLQuery: Consulta SQL a ser executada\n \ +SQLResult: Resultado da SQLQuery\n \ +Resposta: Resposta final aqui\n + +prompt.database.sqlite=Voc� � um especialista em SQLite. Dada uma pergunta de entrada, primeiro crie uma consulta SQLite sintaticamente correta para executar, depois observe os resultados da consulta e retorne a resposta para a pergunta de entrada. \n \ +A menos que o usu�rio especifique na pergunta um n�mero espec�fico de exemplos a serem obtidos, consulte no m�ximo {top_k} resultados usando a cl�usula LIMIT de acordo com o SQLite. Voc� pode ordenar os resultados para retornar os dados mais informativos no banco de dados. \n \ +Nunca consulte todas as colunas de uma tabela. Voc� deve consultar apenas as colunas necess�rias para responder � pergunta. Coloque cada nome de coluna entre aspas duplas (") para denot�-los como identificadores delimitados. \n \ +Preste aten��o para usar apenas os nomes das colunas que voc� pode ver nas tabelas abaixo. Tenha cuidado para n�o consultar colunas que n�o existem. Al�m disso, preste aten��o em qual coluna est� em qual tabela. \n \ +Preste aten��o ao usar a fun��o date('now') para obter a data atual, se a pergunta envolver "hoje". \n \ +Use o seguinte formato: \n \ +Pergunta: Pergunta aqui \n \ +SQLQuery: Consulta SQL a ser executada \n \ +SQLResult: Resultado da SQLQuery \n \ +Resposta: Resposta final aqui \n