Bird
0
0

Identify the issue in this code snippet:

medium📝 Debug Q6 of 15
LangChain - Document Loading
Identify the issue in this code snippet:
loader = DirectoryLoader('docs', glob='*.pdf')
docs = loader.load_files()
ADirectoryLoader cannot load PDF files.
BThe glob pattern '*.pdf' is invalid syntax.
CThe directory 'docs' must be an absolute path.
DThe method <code>load_files()</code> does not exist; should use <code>load()</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Check method names

    The correct method to load documents is load(), not load_files().
  2. Step 2: Validate glob pattern

    '*.pdf' is a valid glob pattern.
  3. Step 3: Directory path

    Relative paths like 'docs' are allowed.
  4. Step 4: File type support

    DirectoryLoader supports PDF files if proper loaders are configured.
  5. Final Answer:

    The method load_files() does not exist; should use load(). -> Option D
  6. Quick Check:

    Use load(), not load_files() [OK]
Quick Trick: Use load(), not load_files() [OK]
Common Mistakes:
  • Using non-existent method load_files()
  • Assuming glob pattern '*.pdf' is invalid
  • Thinking relative paths are disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes