Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
LangChain - Prompt Templates
Identify the error in this code snippet:
base_prompt = PromptTemplate(template="{greeting}, {name}!")
partial_prompt = base_prompt.partial(greeting)
print(partial_prompt.format(name="Sam"))
AMissing value for 'greeting' in partial() call
BIncorrect method name, should be set_partial()
Cformat() missing required argument 'name'
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check partial() usage

    partial() requires keyword arguments to fill variables, but 'greeting' is passed without a value.
  2. Step 2: Identify missing value error

    Passing just 'greeting' causes a syntax or runtime error because value is missing.
  3. Final Answer:

    Missing value for 'greeting' in partial() call -> Option A
  4. Quick Check:

    partial() needs variable=value pairs [OK]
Quick Trick: partial() needs variable=value pairs [OK]
Common Mistakes:
  • Passing variable name without value
  • Using wrong method names
  • Ignoring required arguments in format()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes