Bird
0
0

Why does this code raise an error?

medium📝 Debug Q7 of 15
LangChain - RAG Chain Construction
Why does this code raise an error?
rag_chain = RetrievalQA.from_chain_type(llm=llm, retriever='my_retriever')
Allm must be a string, not an object
BRetriever must be an object, not a string
Cfrom_chain_type requires no arguments
DThe method name is misspelled
Step-by-Step Solution
Solution:
  1. Step 1: Check retriever argument type

    Retriever must be a retriever object, not a string identifier.
  2. Step 2: Understand type mismatch error

    Passing a string instead of a retriever object causes a type error.
  3. Final Answer:

    Retriever must be an object, not a string -> Option B
  4. Quick Check:

    Retriever type must be object [OK]
Quick Trick: Retriever argument must be an object, not string [OK]
Common Mistakes:
  • Passing retriever as string name
  • Confusing llm type requirements
  • Assuming method name is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes