Spaces:
Sleeping
Sleeping
File size: 506 Bytes
9a2d4ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import os
from langchain_community.document_loaders import PyPDFLoader
def load_all_pdfs(folder_path="data"):
"""Load all PDF files from a folder into LangChain documents."""
documents = []
if not os.path.isdir(folder_path):
return documents
for file_name in sorted(os.listdir(folder_path)):
if file_name.lower().endswith(".pdf"):
loader = PyPDFLoader(os.path.join(folder_path, file_name))
documents.extend(loader.load())
return documents
|