Spaces:
Sleeping
Sleeping
File size: 585 Bytes
b877b0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
"""
document_loader.py
Module for loading documents from PDF files using PyMuPDFLoader.
"""
from langchain_community.document_loaders import PyMuPDFLoader
def load_document(file_path):
"""Loads a document from a PDF file.
Args:
file_path (str): Path to the PDF file.
Returns:
list: A list of documents if loaded successfully, else an empty list.
"""
loader = PyMuPDFLoader(file_path)
try:
documents = loader.load()
except Exception as e:
print(f"Error loading document: {e}")
documents = []
return documents
|