ramhemanth580's picture
Upload 8 files
8d66574 verified
raw
history blame contribute delete
No virus
1.29 kB
from examples import get_example_selector
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder,FewShotChatMessagePromptTemplate,PromptTemplate
example_prompt = ChatPromptTemplate.from_messages(
[
("human", "{input}\nSQLQuery:"),
("ai", "{query}"),
]
)
few_shot_prompt = FewShotChatMessagePromptTemplate(
example_prompt=example_prompt,
example_selector=get_example_selector(),
input_variables=["input","top_k"],
)
final_prompt = ChatPromptTemplate.from_messages(
[
(
"system", """You are a MySQL expert, Given an input question ,create a syntactically correct MySQL query to run.Unless otherwise specificed.\n\n
Here is the relevant table info: {table_info}\n\n
Below are a number of examples of questions and their corresponding SQL queries. Return the syntactically correct SQL query only and nothing else.\n\n
"""
),
few_shot_prompt,
MessagesPlaceholder(variable_name="messages"),
("human", "{input}"),
]
)
answer_prompt = PromptTemplate.from_template(
"""Given the following user question, corresponding SQL query, and SQL result, answer the user question.
Question: {question}
SQL Query: {query}
SQL Result: {result}
Answer: """
)