You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python DirectoryLoader only accepts a single loader_cls, so every RAG app has to spin up one loader per extension and merge the results. That class also lives in langchain-community, which is being sunset (langchain-community#674). A matching suffix_loader_map PR was closed as part of that wind-down (langchain-community#571).
Please add a first-party Python DirectoryLoader (in langchain or langchain-core) that:
Accepts loaders={".pdf": PyPDFLoader, ".txt": TextLoader, ...} (classes or factories).
Keeps a single-loader path for backward compatibility (loader_cls=).
Skips unknown extensions with a warning (or silent_errors=True), instead of failing the whole folder.
Matches JS behavior closely enough that the docs can show the same example in both languages.
This is JS/Python parity for the most common RAG ingest path: “here is a docs folder, load it.”
Use Case
I'm building RAG over a real knowledge folder, not a simple dataset. The folder has PDFs, notes (.txt/.md), spreadsheets (.csv), and Word files (.docx).
Submission checklist
Package (Required)
Feature Description
Python has no first-party way to load a mixed folder (pdf + txt + csv + docx) with the correct parser per file in one call.
JS
DirectoryLoaderalready takes a map of extension → loader factory, and that is the documented JS API:Python
DirectoryLoaderonly accepts a singleloader_cls, so every RAG app has to spin up one loader per extension and merge the results. That class also lives inlangchain-community, which is being sunset (langchain-community#674). A matchingsuffix_loader_mapPR was closed as part of that wind-down (langchain-community#571).Please add a first-party Python
DirectoryLoader(inlangchainorlangchain-core) that:loaders={".pdf": PyPDFLoader, ".txt": TextLoader, ...}(classes or factories).loader_cls=).silent_errors=True), instead of failing the whole folder.This is JS/Python parity for the most common RAG ingest path: “here is a docs folder, load it.”
Use Case
I'm building RAG over a real knowledge folder, not a simple dataset. The folder has PDFs, notes (
.txt/.md), spreadsheets (.csv), and Word files (.docx).Today in Python I have to write:
That is easy to get wrong (missed globs, duplicated files, one bad PDF aborting a run) and it is the first thing every RAG tutorial hits.
JS users already write one call with a loader map. Python users should be able to do the same:
With
langchain-communitysunsetting, this should live in first-party LangChain so the standard ingest path does not disappear.Proposed Solution
Add
DirectoryLoadertolangchain(orlangchain-core) with a backward-compatible API:loader_cls=...stays valid (current Python behavior).loaders={".ext": Loader | Callable[[str], BaseLoader]}is the new path.path.suffix.silent_errors=True, else raise a clear error naming the file.load_with_errors() -> (docs, [(path, exc), ...]).I can implement this and add unit tests (mixed folder, unknown suffix, old
loader_clsstill works) if a maintainer assigns the issue.Alternatives Considered
I've tried using multiple
DirectoryLoadercalls and concatenating the results.Alternative approaches I considered:
DirectoryLoadercalls + list concat - works, but it is boilerplate every RAG app copies.MergedDataLoader- still requires constructing one loader per type/file.GenericLoader.from_filesystem- one parser for the whole tree, not a per-extension map.langchain-communityDirectoryLoader- community is sunsetting; PR Is human_prefix necessary for ConversationalAgent? #571 (suffix_loader_map) was closed for that reason.silent_errors=True- already exists; it skips failures, it does not pick the right loader per file type.These don't work as a first-class solution because they either stay in a sunset package, or they still force users to write one loader per file type.
Additional Context
Related:
langchain-communitylangchain-community#674 (community sunset)I am happy to open a PR once a maintainer approves the approach and assigns this issue.
Social handles (optional)
No response