-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unstructured, community, initialize langchain-unstructured package #22779
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dosubot
bot
added
the
size:L
This PR changes 100-499 lines, ignoring generated files.
label
Jun 11, 2024
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
dosubot
bot
added
Ɑ: doc loader
Related to document loader module (not documentation)
🤖:improvement
Medium size change to existing code to handle new use-cases
labels
Jun 11, 2024
Coniferish
commented
Jun 11, 2024
libs/community/tests/integration_tests/document_loaders/test_unstructured.py
Outdated
Show resolved
Hide resolved
Previously, the API Loaders inherited from their respective File/FileIO loaders (which both interhited from the Base Loader). This was problematic for switching from having 'unstructured' as a dependency to 'unstructured-client' because the Base Loader checked if 'unstructured' was installed. Now the 'unstructured'/'unstructured-client' check happens in the get_elements_from_api function and the other Loaders are responsible for checking the packages they depend on. With the API loaders inheriting directly from the Base Loader now, they also now initialize their 'file'/'file_path' attributes and call the super.__init__() method of the Base Loader directly.
Refactor calls to get_elements_from_api so that Loaders handle single or multiple files. Change metadata_filename variable name in tests/unstructured_kwargs. Import elements_from_json. Etc.
…used import, move tests to match module
…again and update _get_elements method. Also add test for UnstructuredFileIOLoader
Coniferish
commented
Jun 17, 2024
Coniferish
commented
Jun 17, 2024
libs/community/langchain_community/document_loaders/unstructured.py
Outdated
Show resolved
Hide resolved
Coniferish
commented
Jun 17, 2024
libs/community/langchain_community/document_loaders/unstructured.py
Outdated
Show resolved
Hide resolved
Coniferish
commented
Jun 17, 2024
libs/community/langchain_community/document_loaders/unstructured.py
Outdated
Show resolved
Hide resolved
Coniferish
commented
Jun 17, 2024
libs/community/langchain_community/document_loaders/unstructured.py
Outdated
Show resolved
Hide resolved
Also, remove API Loaders dependency on unstructured and add comments.
Coniferish
commented
Jun 17, 2024
libs/community/langchain_community/document_loaders/unstructured.py
Outdated
Show resolved
Hide resolved
… classes Also, change type hints for List/list, Dict/dict, etc. and improve docstrings
add dynamic field feature to langchain_milvus more unittest, more robustic plan to deprecate the `metadata_field` in the future, because it's function is the same as `enable_dynamic_field`, but the latter one is a more advanced concept in milvus Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Erick Friis <erick@langchain.dev>
- **cli: remove snapshot flag from pytest defaults** - **x** - **x**
efriis
changed the title
community: Update unstructured API loaders to use sdk:
unstructured, community, initialize langchain-unstructured package
Jul 24, 2024
efriis
approved these changes
Jul 24, 2024
dosubot
bot
added
the
lgtm
PR looks good. Use to confirm that a PR is ready for merging.
label
Jul 24, 2024
olgamurraft
pushed a commit
to olgamurraft/langchain
that referenced
this pull request
Aug 16, 2024
…angchain-ai#22779) #### Update (2): A single `UnstructuredLoader` is added to handle both local and api partitioning. This loader also handles single or multiple documents. #### Changes in `community`: Changes here do not affect users. In the initial process of using the SDK for the API Loaders, the Loaders in community were refactored. Other changes include: The `UnstructuredBaseLoader` has a new check to see if both `mode="paged"` and `chunking_strategy="by_page"`. It also now has `Element.element_id` added to the `Document.metadata`. `UnstructuredAPIFileLoader` and `UnstructuredAPIFileIOLoader`. As such, now both directly inherit from `UnstructuredBaseLoader` and initialize their `file_path`/`file` attributes respectively and implement their own `_post_process_elements` methods. -------- #### Update: New SDK Loaders in a [partner package](https://python.langchain.com/v0.1/docs/contributing/integrations/#partner-package-in-langchain-repo) are introduced to prevent breaking changes for users (see discussion below). ##### TODO: - [x] Test docstring examples -------- - **Description:** UnstructuredAPIFileIOLoader and UnstructuredAPIFileLoader calls to the unstructured api are now made using the unstructured-client sdk. - **New Dependencies:** unstructured-client - [x] **Add tests and docs**: If you're adding a new integration, please include - [x] a test for the integration, preferably unit tests that do not rely on network access, - [x] update the description in `docs/docs/integrations/providers/unstructured.mdx` - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. TODO: - [x] Update https://python.langchain.com/v0.1/docs/integrations/document_loaders/unstructured_file/#unstructured-api - `langchain/docs/docs/integrations/document_loaders/unstructured_file.ipynb` - The description here needs to indicate that users should install `unstructured-client` instead of `unstructured`. Read over closely to look for any other changes that need to be made. - [x] Update the `lazy_load` method in `UnstructuredBaseLoader` to handle json responses from the API instead of just lists of elements. - This method may need to be overwritten by the API loaders instead of changing it in the `UnstructuredBaseLoader`. - [x] Update the documentation links in the class docstrings (the Unstructured documents have moved) - [x] Update Document.metadata to include `element_id` (see thread [here](https://unstructuredw-kbe4326.slack.com/archives/C044N0YV08G/p1718187499818419)) --------- Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Erick Friis <erick@langchain.dev> Co-authored-by: Isaac Francisco <78627776+isahers1@users.noreply.github.com> Co-authored-by: ChengZi <chen.zhang@zilliz.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
community
Related to langchain-community
Ɑ: doc loader
Related to document loader module (not documentation)
🤖:docs
Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder
🤖:enhancement
A large net-new component, integration, or chain. Use sparingly. The largest features
🤖:improvement
Medium size change to existing code to handle new use-cases
lgtm
PR looks good. Use to confirm that a PR is ready for merging.
partner
size:XXL
This PR changes 1000+ lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update (2):
A single
UnstructuredLoader
is added to handle both local and api partitioning. This loader also handles single or multiple documents.Changes in
community
:Changes here do not affect users. In the initial process of using the SDK for the API Loaders, the Loaders in community were refactored.
Other changes include:
The
UnstructuredBaseLoader
has a new check to see if bothmode="paged"
andchunking_strategy="by_page"
. It also now hasElement.element_id
added to theDocument.metadata
.UnstructuredAPIFileLoader
andUnstructuredAPIFileIOLoader
. As such, now both directly inherit fromUnstructuredBaseLoader
and initialize theirfile_path
/file
attributes respectively and implement their own_post_process_elements
methods.Update:
New SDK Loaders in a partner package are introduced to prevent breaking changes for users (see discussion below).
TODO:
Description: UnstructuredAPIFileIOLoader and UnstructuredAPIFileLoader calls to the unstructured api are now made using the unstructured-client sdk.
New Dependencies: unstructured-client
Add tests and docs: If you're adding a new integration, please include
docs/docs/integrations/providers/unstructured.mdx
Lint and test: Run
make format
,make lint
andmake test
from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/Additional guidelines:
TODO:
langchain/docs/docs/integrations/document_loaders/unstructured_file.ipynb
unstructured-client
instead ofunstructured
. Read over closely to look for any other changes that need to be made.lazy_load
method inUnstructuredBaseLoader
to handle json responses from the API instead of just lists of elements.UnstructuredBaseLoader
.element_id
(see thread here)