Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import PyPDFLoader from langchain.document_loaders.
LangChain
from langchain.document_loaders import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing PDFLoader instead of PyPDFLoader
Using TextLoader for PDFs
Forgetting to import the loader
✗ Incorrect
You need to import PyPDFLoader to load PDF files using Langchain.
2fill in blank
mediumComplete the code to create a PyPDFLoader instance for the file 'sample.pdf'.
LangChain
loader = PyPDFLoader([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-PDF file name
Forgetting quotes around the filename
Using a wrong file extension
✗ Incorrect
The loader needs the PDF file path as a string, here 'sample.pdf'.
3fill in blank
hardFix the error in the code to load documents from the loader.
LangChain
documents = loader.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using load_and_split() which does not exist on PyPDFLoader
Using load_data() which does not exist
Using load_documents() which is invalid
✗ Incorrect
The correct method to load documents from the loader is load().
4fill in blank
hardFill both blanks to create a PyPDFLoader and load documents from 'report.pdf'.
LangChain
loader = [1]([2]) documents = loader.load()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using PDFLoader instead of PyPDFLoader
Passing a non-PDF filename
Forgetting quotes around filename
✗ Incorrect
You create the loader with PyPDFLoader and pass the PDF filename 'report.pdf'.
5fill in blank
hardFill all three blanks to import PyPDFLoader, create a loader for 'file.pdf', and load documents.
LangChain
from langchain.document_loaders import [1] loader = [2]([3]) docs = loader.load()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up import and instance names
Using wrong loader class
Passing wrong filename
✗ Incorrect
Import PyPDFLoader, create an instance with 'file.pdf', then load.