Building a retrieval prompt template
Now your documents have been ingested into vector database and are ready for retrieval, you'll need to design a chat prompt template to combine the retrieved document chunks with the user input question.
The general structure of the prompt has already been provided; your goal is to insert the correct input variable placeholders into the message
string and convert the string into a chat prompt template.
This exercise is part of the course
Developing LLM Applications with LangChain
Exercise instructions
- Complete the message string to add a placeholder for dynamic insertion of the retrieved documents called
context
and user input questionquestion
. - Create a chat prompt template from
message
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Add placeholders to the message string
message = """
Answer the following question using the context provided:
Context:
____
Question:
____
Answer:
"""
# Create a chat prompt template from the message string
prompt_template = ChatPromptTemplate.____([("____", ____)])