Skip to main content

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

Metadata

Release files for gigachain-unstructured 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gigachain-unstructured 0.1.2
File Size Uploaded
gigachain_unstructured-0.1.2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gigachain-unstructured 0.1.2
File Interpreter ABI Platform
gigachain_unstructured-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / gigachain_unstructured-0.1.2.tar.gz

Download URL gigachain_unstructured-0.1.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3b88c12f516ed41f706b553bc2acf95b9fcf17015ff9ff000199109d9133ef62
BLAKE2b-256 checksum
How to use checksums
9d686cdb817d970c1833df0f34500e4b609954080c435018c89f14714e6d6efc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

Release files / gigachain_unstructured-0.1.2-py3-none-any.whl

Download URL gigachain_unstructured-0.1.2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
045ba95139d87356df7c40dff9bea2e04ec176a1e05b7949a83a931a21d3e2af
BLAKE2b-256 checksum
How to use checksums
9ad6f9a4d6d0d0fd41d8ad7af2d7cb0b6b799d0eb49e57f556d179dbb9261167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page