Skip to content

Commit

Permalink
Add prestodb prompt (langchain-ai#4516)
Browse files Browse the repository at this point in the history
Add a PrestoDB prompt
  • Loading branch information
yanghua committed May 12, 2023
1 parent 7bcf238 commit e942db3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions langchain/chains/sql_database/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,28 @@
template=_clickhouse_prompt,
)

_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.
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 PrestoDB. 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.
Use the following format:
Question: "Question here"
SQLQuery: "SQL Query to run"
SQLResult: "Result of the SQLQuery"
Answer: "Final answer here"
Only use the following tables:
{table_info}
Question: {input}"""

PRESTODB_PROMPT = PromptTemplate(
input_variables=["input", "table_info", "top_k"],
template=_prestodb_prompt,
)


SQL_PROMPTS = {
"duckdb": DUCKDB_PROMPT,
Expand All @@ -253,4 +275,5 @@
"postgresql": POSTGRES_PROMPT,
"sqlite": SQLITE_PROMPT,
"clickhouse": CLICKHOUSE_PROMPT,
"prestodb": PRESTODB_PROMPT,
}

0 comments on commit e942db3

Please sign in to comment.