mirror of
https://github.com/langchain-ai/langchain-unstructured.git
synced 2026-07-19 22:33:31 -04:00
[PR #17] unstructured[minor]: 08 - Refactoring 17 unstructured loaders #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langchain-ai/langchain-unstructured/pull/17
Author: @pprados
Created: 2/27/2025
Status: 🔄 Open
Base:
main← Head:pprados/08-unstructured📝 Commits (1)
fbf9fc1Refactor with PDF standard compatibility📊 Changes
12 files changed (+5295 additions, -2060 deletions)
View changed files
📝
libs/unstructured/README.md(+8 -8)➕
libs/unstructured/example_docs/hello.pdf(+0 -0)➕
libs/unstructured/example_docs/layout-parser-paper-password.pdf(+0 -0)📝
libs/unstructured/langchain_unstructured/__init__.py(+9 -2)📝
libs/unstructured/langchain_unstructured/document_loaders.py(+657 -50)📝
libs/unstructured/poetry.lock(+3508 -1949)📝
libs/unstructured/pyproject.toml(+45 -23)➕
libs/unstructured/tests/integration_tests/conftest.py(+19 -0)📝
libs/unstructured/tests/integration_tests/test_document_loaders.py(+72 -28)➕
libs/unstructured/tests/integration_tests/test_parser.py(+314 -0)📝
libs/unstructured/tests/unit_tests/test_imports.py(+2 -0)➕
libs/unstructured/unstructured_pdfloader.ipynb(+661 -0)📄 Description
In this PR, we propose a migration of the various
Unstructured*Loaderimplementations to thelangchain-unstructuredpackage.Improvements
We’ve made several key improvements:
langchain-community)langchain-community(seetest_migration.py)Loaderis split into aLoader/Parserto allow usage withGenericLoader#prefixes) and tables in either Markdown or HTML format. It’s possible to revert to the original behavior by changing a few parameters.keep_header_footer=False)Pathobjects or stringsweb_urlIOobjectauto,fast,hi_res, andocr_only)lazy_load()UnstructuredLoaderadditionally supports a list of PATHs infile_path. While we don’t consider this very clean (why only this loader? Why no plural? The user could just loop), we replicate the behavior fromlangchain-community.langchain-unstructureddependencies offer the same extras asunstructured(csv, pdf, docx, etc.). This allows specifying a dependency onlangchain-unstructuredlimited to certain file types (langchain-unstructured[pdf]). The previous behavior pulled in all possible formats, resulting in a package too large for environments like AWS Lambda.With this PR, it will be possible to mark 17 Loader as "deprecated". There will remain 5 dependencies on
unstructuredinlangchain-community.Once this version is released, we plan to propose a PR to
langchain-communityto mark allUnstructured*Loaderas@deprecated. Any changes to default parameter values will be explained in the comments.Other dependencies on Unstructured in
langchain-communityThere are not part of unstructured
Unstructured, even thoughUnstructuredCHMLoaderexists. Thelangchain-communityversion doesn’t work with the files we tested. We are leaving this loader as-is.UnstructuredLakeFSLoaderSeleniumURLLoaderS3FileLoader. UseGenericLoader+CloudBlobLoaderUnstructuredHtmlEvaluatorpyproject.toml
unstructuredis a framework that can pull in a large number of dependencies, depending on the file formats it needs to process. The framework offers various extras to include only the strictly necessary dependencies, for example:unstructured[pdf,csv].langchain-unstructureddoes not currently work this way. It pulls in all dependencies fromunstructured, resulting in very large projects that are incompatible with environments that have size limitations, such as AWS Lambda.The change to
pyproject.tomlreplicates the different extras provided byunstructuredand propagates them intolangchain-unstructured.PDF
This is one part of a larger Pull Request (PR) that is too large to be submitted all at once. This specific part focuses on updating the
UnstructuredPDFParserandUnstructuredPDFLoader.For more details, see here
Note
I will not split this PR into multiple smaller PRs, each covering a single loader. That approach would take too much time for zero benefit (I’ve had some bad experiences with it). Either this PR works for you, and I’ll make the requested changes, or you can close it and ignore it. It will then be up to another contributor to migrate the various
Unstructured*Loaderto this project.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.