Bird
0
0

Which of the following is the correct way to create a ChatPromptTemplate with a user input placeholder named 'name'?

easy📝 Syntax Q12 of 15
LangChain - Prompt Templates
Which of the following is the correct way to create a ChatPromptTemplate with a user input placeholder named 'name'?
AChatPromptTemplate.from_template('Hello {name}!')
BChatPromptTemplate('Hello $name!')
CChatPromptTemplate.create('Hello {{name}}!')
DChatPromptTemplate.new('Hello %name%!')
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct placeholder syntax

    Langchain uses curly braces {name} inside from_template method to define placeholders.
  2. Step 2: Check method and syntax correctness

    Only ChatPromptTemplate.from_template('Hello {name}!') uses from_template and correct {name} placeholder syntax.
  3. Final Answer:

    ChatPromptTemplate.from_template('Hello {name}!') -> Option A
  4. Quick Check:

    Use from_template with {placeholder} [OK]
Quick Trick: Use from_template and {placeholder} syntax [OK]
Common Mistakes:
  • Using wrong placeholder symbols like $ or % or double braces
  • Using non-existent methods like create or new

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes