Spaces:
Sleeping
Sleeping
| 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 | |