An integration package connecting Unstructured and LangChain
Project description
langchain-unstructured
This package contains the LangChain integration with Unstructured
Installation
pip install -U langchain-unstructured
And you should configure credentials by setting the following environment variables:
export UNSTRUCTURED_API_KEY="your-api-key"
Loaders
Partition and load files using either the unstructured-client
sdk and the
Unstructured API or locally using the unstructured
library.
API:
To partition via the Unstructured API pip install unstructured-client
and set
partition_via_api=True
and define api_key
. If you are running the unstructured API
locally, you can change the API rule by defining url
when you initialize the
loader. The hosted Unstructured API requires an API key. See the links below to
learn more about our API offerings and get an API key.
Local:
By default the file loader uses the Unstructured partition
function and will
automatically detect the file type.
In addition to document specific partition parameters, Unstructured has a rich set of "chunking" parameters for post-processing elements into more useful text segments for uses cases such as Retrieval Augmented Generation (RAG). You can pass additional Unstructured kwargs to the loader to configure different unstructured settings.
Setup:
pip install -U langchain-unstructured
pip install -U unstructured-client
export UNSTRUCTURED_API_KEY="your-api-key"
Instantiate:
from langchain_unstructured import UnstructuredLoader
loader = UnstructuredLoader(
file_path = ["example.pdf", "fake.pdf"],
api_key=UNSTRUCTURED_API_KEY,
partition_via_api=True,
chunking_strategy="by_title",
strategy="fast",
)
Load:
docs = loader.load()
print(docs[0].page_content[:100])
print(docs[0].metadata)
References
https://docs.unstructured.io/api-reference/api-services/sdk https://docs.unstructured.io/api-reference/api-services/overview https://docs.unstructured.io/open-source/core-functionality/partitioning https://docs.unstructured.io/open-source/core-functionality/chunking
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file langchain_unstructured-0.1.1.tar.gz
.
File metadata
- Download URL: langchain_unstructured-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26c18a59f9d6f153d2ac664dbcbd768adde2053ff1588127fdbff82aa5973cb3 |
|
MD5 | 56438b828473e212a132c3996fa0e020 |
|
BLAKE2b-256 | 547c84a3b03b43b3effac16bfeda9ed62e35a72f19bd442f3faf2e70d9baaa4e |
File details
Details for the file langchain_unstructured-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: langchain_unstructured-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0aff11e6fd828cfbb6784fa2ddf03d132c13891ce7184ec4b683fd8e89e9474 |
|
MD5 | a3db271099235cf767fc42df98158f0c |
|
BLAKE2b-256 | 5a2ca0c4269f9339f1c19d22d6ffaaa156105690f8a411457af7de7a9457a308 |