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.
Bu egzersiz
Developing LLM Applications with LangChain
kursunun bir parçasıdırEgzersiz talimatları
- 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.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# 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([("____", ____)])