Bird
0
0

You want to create a reusable prompt template that asks for a user's favorite color and hobby. Which approach best uses templates to keep your prompts consistent and easy to update?

hard📝 Application Q15 of 15
LangChain - Prompt Templates
You want to create a reusable prompt template that asks for a user's favorite color and hobby. Which approach best uses templates to keep your prompts consistent and easy to update?
AUse separate templates for color and hobby and combine them manually
BCreate a template with placeholders {color} and {hobby}, then fill them each time you ask
CWrite a new prompt string every time with the user's answers included
DHardcode the questions and ignore user input for simplicity
Step-by-Step Solution
Solution:
  1. Step 1: Identify the goal of reusability and consistency

    Using one template with placeholders for both color and hobby lets you reuse the prompt easily and keep it consistent.
  2. Step 2: Compare options for maintainability

    Writing new strings each time or splitting templates adds complexity and risks inconsistency.
  3. Final Answer:

    Create a template with placeholders {color} and {hobby}, then fill them each time you ask -> Option B
  4. Quick Check:

    Single template with placeholders = C [OK]
Quick Trick: Use one template with multiple placeholders for related data [OK]
Common Mistakes:
  • Writing new prompt strings every time
  • Splitting related questions into separate templates
  • Ignoring user input to simplify prompts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes