@ -3,6 +3,11 @@ from langchain.output_parsers.list import CommaSeparatedListOutputParser
fromlangchain.prompts.promptimportPromptTemplate
fromlangchain.prompts.promptimportPromptTemplate
PROMPT_SUFFIX="""Only use the following tables:
{table_info}
Question:{input}"""
_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.
_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.
_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}
Question:{query}
@ -53,14 +55,11 @@ SQLQuery: SQL Query to run
SQLResult:ResultoftheSQLQuery
SQLResult:ResultoftheSQLQuery
Answer:Finalanswerhere
Answer:Finalanswerhere
Onlyusethefollowingtables:
"""
{table_info}
Question:{input}"""
DUCKDB_PROMPT=PromptTemplate(
DUCKDB_PROMPT=PromptTemplate(
input_variables=["input","table_info","top_k"],
input_variables=["input","table_info","top_k"],
template=_duckdb_prompt,
template=_duckdb_prompt+PROMPT_SUFFIX,
)
)
_googlesql_prompt="""You are a GoogleSQL expert. Given an input question, first create a syntactically correct GoogleSQL query to run, then look at the results of the query and return the answer to the input question.
_googlesql_prompt="""You are a GoogleSQL expert. Given an input question, first create a syntactically correct GoogleSQL query to run, then look at the results of the query and return the answer to the input question.
_clickhouse_prompt="""You are a ClickHouse expert. Given an input question, first create a syntactically correct Clic query to run, then look at the results of the query and return the answer to the input question.
_clickhouse_prompt="""You are a ClickHouse expert. Given an input question, first create a syntactically correct Clic query to run, then look at the results of the query and return the answer to the input question.
@ -241,14 +221,11 @@ SQLQuery: "SQL Query to run"
SQLResult:"Result of the SQLQuery"
SQLResult:"Result of the SQLQuery"
Answer:"Final answer here"
Answer:"Final answer here"
Onlyusethefollowingtables:
"""
{table_info}
Question:{input}"""
CLICKHOUSE_PROMPT=PromptTemplate(
CLICKHOUSE_PROMPT=PromptTemplate(
input_variables=["input","table_info","top_k"],
input_variables=["input","table_info","top_k"],
template=_clickhouse_prompt,
template=_clickhouse_prompt+PROMPT_SUFFIX,
)
)
_prestodb_prompt="""You are a PrestoDB expert. Given an input question, first create a syntactically correct PrestoDB query to run, then look at the results of the query and return the answer to the input question.
_prestodb_prompt="""You are a PrestoDB expert. Given an input question, first create a syntactically correct PrestoDB query to run, then look at the results of the query and return the answer to the input question.