Created
July 21, 2023 21:10
-
-
Save samkeen/be1cf94df883a74aa203cbb1693ebe6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Supply a custom prompt to a LangChain QA Chain | |
system_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. | |
{context} | |
Question: {question} | |
Helpful Answer:""" | |
messages = [ | |
SystemMessagePromptTemplate.from_template(system_template), | |
HumanMessagePromptTemplate.from_template("{question}"), | |
] | |
chat_prompt = ChatPromptTemplate.from_messages(messages) | |
# Instantiate a Question/Answer Langchain chain. | |
chain = load_qa_chain(llm, chain_type="stuff", verbose=True, prompt=chat_prompt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment