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.
Questo esercizio fa parte del corso
Developing LLM Applications with LangChain
Istruzioni dell'esercizio
- Complete the message string to add a placeholder for dynamic insertion of the retrieved documents called
contextand user input questionquestion. - Create a chat prompt template from
messageusing the.from_messages()method with the "human" role.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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.from_messages([("____", ____)])