Bird
0
0

Consider this custom loader code:

medium📝 Predict Output Q4 of 15
LangChain - Document Loading
Consider this custom loader code:
from langchain.document_loaders.base import BaseLoader

class ExampleLoader(BaseLoader):
    def load(self):
        return ["page1", "page2", "page3"]

loader = ExampleLoader()
docs = loader.load()
print(docs)

What will be printed?
AA string 'page1page2page3'
BAn error because load must return Document objects
CAn empty list []
D['page1', 'page2', 'page3']
Step-by-Step Solution
Solution:
  1. Step 1: Analyze load method

    It returns a list of strings: ["page1", "page2", "page3"].
  2. Step 2: Check print output

    Printing docs will output the list as is.
  3. Final Answer:

    ['page1', 'page2', 'page3'] -> Option D
  4. Quick Check:

    load returns list, print shows list [OK]
Quick Trick: load returns list, print outputs list directly [OK]
Common Mistakes:
  • Assuming load must return Document objects only
  • Expecting concatenated string output
  • Thinking an error will occur on print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes