Skip to content

Commit 213c2e3

Browse files
authored
Sql prompt improvement (#787)
Co-authored-by: Francisco Ingham <>
1 parent 2e0219c commit 213c2e3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

langchain/chains/sql_database/prompt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from langchain.prompts.prompt import PromptTemplate
44

55
_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 using the LIMIT clause. You can order the results by a relevant column to return the most interesting examples in the database.
6+
7+
Never query for all the columns from a specific table, only ask for a the few relevant columns given the question.
8+
9+
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.
10+
611
Use the following format:
712
813
Question: "Question here"

0 commit comments

Comments
 (0)