Bird
0
0

Identify the error in this A/B testing code snippet:

medium📝 Debug Q14 of 15
LangChain - Evaluation and Testing
Identify the error in this A/B testing code snippet:
from langchain import PromptTemplate
prompt1 = PromptTemplate(template='Hello {name}')
prompt2 = PromptTemplate(template='Hi {name}')
inputs = {'name': 'Bob'}
results = [prompt1.format(inputs), prompt2.format(inputs)]
print(results)
APromptTemplate missing template argument
BUsing format() without unpacking inputs dictionary
Cinputs dictionary missing required key
Dprint statement syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Check how format() is called

    format() expects keyword arguments, so inputs must be unpacked with **inputs.
  2. Step 2: Identify the error

    Code passes inputs as a single dict argument, causing a TypeError.
  3. Final Answer:

    Using format() without unpacking inputs dictionary -> Option B
  4. Quick Check:

    Use **inputs to unpack dict for format() [OK]
Quick Trick: Always unpack dict with ** when calling format() [OK]
Common Mistakes:
MISTAKES
  • Passing dict directly instead of unpacking
  • Forgetting to import PromptTemplate
  • Using wrong print syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes