Recall & Review
beginner
What is a PromptTemplate in Langchain?
A PromptTemplate is a way to create text prompts with placeholders that you can fill with different values. It helps you build dynamic prompts easily.
Click to reveal answer
beginner
How do you define placeholders in a PromptTemplate?
Placeholders are defined using curly braces like
{placeholder_name} inside the template string. These get replaced with actual values when you run the prompt.Click to reveal answer
beginner
What method do you use to fill a PromptTemplate with values?
You use the
format() method and pass keyword arguments with keys matching the placeholder names to fill the template.Click to reveal answer
beginner
Why use PromptTemplate instead of plain strings?
PromptTemplate helps keep your prompts organized and reusable. It avoids mistakes by clearly marking where values go and makes it easy to change parts without rewriting the whole prompt.
Click to reveal answer
beginner
Show a simple example of creating and using a PromptTemplate.
Example:<br>template = "Hello, {name}!"<br>prompt = PromptTemplate(template=template)<br>filled = prompt.format(name="Alice")<br>Output: "Hello, Alice!"
Click to reveal answer
What symbol is used to mark placeholders in a PromptTemplate?
✗ Incorrect
Placeholders in PromptTemplate are marked with curly braces {}.
Which method fills a PromptTemplate with actual values?
✗ Incorrect
The format() method is used to replace placeholders with real values.
Why is using PromptTemplate helpful?
✗ Incorrect
PromptTemplate helps keep prompts organized and reusable with dynamic placeholders.
If your template is "Hi, {user}!", how do you fill it with user='Bob'?
✗ Incorrect
You use format() with the placeholder name as keyword argument.
What happens if you forget to provide a value for a placeholder?
✗ Incorrect
Missing values for placeholders cause an error during format() call.
Explain what a PromptTemplate is and why it is useful in Langchain.
Think about how you would write a letter with blanks to fill in later.
You got /4 concepts.
Describe the steps to create and use a PromptTemplate with an example.
Imagine filling out a form with your name and details.
You got /4 concepts.