Bird
0
0

What is wrong with this code snippet for comparing prompt versions? from langchain import PromptTemplate prompt_v1 = PromptTemplate('Hello {name}') prompt_v2 = PromptTemplate('Hi {name}')

medium📝 Debug Q6 of 15
LangChain - LangSmith Observability
What is wrong with this code snippet for comparing prompt versions? from langchain import PromptTemplate prompt_v1 = PromptTemplate('Hello {name}') prompt_v2 = PromptTemplate('Hi {name}')
APromptTemplate does not exist in Langchain
BPromptTemplate cannot have variables in curly braces
CPromptTemplate must be imported from langchain.prompts
DPromptTemplate requires a 'template=' keyword argument
Step-by-Step Solution
Solution:
  1. Step 1: Check PromptTemplate constructor syntax

    PromptTemplate requires the template string to be passed as template='...' keyword argument.
  2. Step 2: Identify error in code

    The code passes the template string as a positional argument, which causes an error.
  3. Final Answer:

    PromptTemplate requires a 'template=' keyword argument -> Option D
  4. Quick Check:

    PromptTemplate needs template= keyword [OK]
Quick Trick: Always use template= when creating PromptTemplate [OK]
Common Mistakes:
MISTAKES
  • Passing template as positional argument
  • Thinking variables are not allowed
  • Wrong import path assumption

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes