Bird
0
0

Given this Langchain prompt template:

medium📝 Predict Output Q4 of 15
LangChain - RAG Chain Construction
Given this Langchain prompt template:
template = "Hello, {name}! Your task is: {task}."
prompt = template.format(name="Alice", task="Translate text")
print(prompt)

What will be printed?
AHello, {name}! Your task is: {task}.
BHello, Alice! Your task is: Translate text.
CHello, Alice! Your task is: {task}.
DError: Missing variable
Step-by-Step Solution
Solution:
  1. Step 1: Understand format method effect

    The format method replaces placeholders {name} and {task} with provided values.
  2. Step 2: Substitute values in template

    "{name}" becomes "Alice" and "{task}" becomes "Translate text" in the string.
  3. Final Answer:

    Hello, Alice! Your task is: Translate text. -> Option B
  4. Quick Check:

    Formatted prompt = replaced placeholders [OK]
Quick Trick: format() replaces placeholders with given values [OK]
Common Mistakes:
  • Expecting placeholders to remain unchanged
  • Thinking format method causes error without all variables
  • Confusing print output with template string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes