Bird
0
0

Which of the following is the correct way to create a PromptTemplate in Langchain?

easy📝 Syntax Q12 of 15
LangChain - LangSmith Observability
Which of the following is the correct way to create a PromptTemplate in Langchain?
APromptTemplate(prompt="Hello {name}", args=["name"])
BPromptTemplate(name="Hello {name}", variables=["name"])
CPromptTemplate(text="Hello {name}", inputs=["name"])
DPromptTemplate(template="Hello {name}", input_variables=["name"])
Step-by-Step Solution
Solution:
  1. Step 1: Recall PromptTemplate syntax

    The correct constructor uses 'template' for the prompt text and 'input_variables' for placeholders.
  2. Step 2: Check each option

    Only PromptTemplate(template="Hello {name}", input_variables=["name"]) uses 'template' and 'input_variables' correctly; others use wrong parameter names.
  3. Final Answer:

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

    Correct parameters = template + input_variables [OK]
Quick Trick: Remember: 'template' and 'input_variables' are required keys [OK]
Common Mistakes:
MISTAKES
  • Using 'name' instead of 'template' for prompt text
  • Using 'variables' instead of 'input_variables'
  • Confusing parameter names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes