Bird
0
0

Identify the error in this LangChain code snippet for question reformulation:

medium📝 Debug Q6 of 15
LangChain - Conversational RAG
Identify the error in this LangChain code snippet for question reformulation:
memory = ConversationBufferMemory
chain = ConversationChain(llm=llm, memory=memory())
chain.run("What is LangChain?")
AConversationBufferMemory is not instantiated correctly
Bllm parameter is missing
Crun method is called incorrectly
DMemory should be passed as a string
Step-by-Step Solution
Solution:
  1. Step 1: Check how ConversationBufferMemory is used

    It is assigned without parentheses, so it's a class, not an instance.
  2. Step 2: Analyze memory parameter usage

    memory() tries to call the instance, but memory is a class, causing error.
  3. Final Answer:

    ConversationBufferMemory is not instantiated correctly -> Option A
  4. Quick Check:

    Instantiate classes with () [OK]
Quick Trick: Always instantiate classes with parentheses () [OK]
Common Mistakes:
  • Forgetting parentheses when creating instances
  • Passing class instead of instance
  • Misunderstanding run method usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes