Bird
0
0

Which of the following is the correct way to define a prompt template with a placeholder named name in Langchain?

easy📝 Syntax Q12 of 15
LangChain - Prompt Templates
Which of the following is the correct way to define a prompt template with a placeholder named name in Langchain?
APromptTemplate(template="Hello, %name%!")
BPromptTemplate(template="Hello, $name!")
CPromptTemplate(template="Hello, <name>!")
DPromptTemplate(template="Hello, {name}!")
Step-by-Step Solution
Solution:
  1. Step 1: Recall Langchain placeholder syntax

    Langchain uses curly braces {} to mark placeholders in prompt templates.
  2. Step 2: Match the correct syntax

    The correct syntax for a placeholder named 'name' is {name}, so the template string should be "Hello, {name}!".
  3. Final Answer:

    PromptTemplate(template="Hello, {name}!") -> Option D
  4. Quick Check:

    Curly braces for placeholders = A [OK]
Quick Trick: Use curly braces {} for placeholders in templates [OK]
Common Mistakes:
  • Using $ or % instead of curly braces
  • Using angle brackets <> which are invalid
  • Forgetting to wrap the template string in quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes