RAG_Project / src /loader.py
Rahbarnisa's picture
Upload 24 files
9a2d4ec verified
raw
history blame contribute delete
506 Bytes
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