Metadata-Version: 2.4
Name: langchain-unstructured
Version: 0.1.2
Summary: An integration package connecting Unstructured and LangChain
License: MIT
License-File: LICENSE
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: local
Requires-Dist: langchain-core (>=0.2.23,<0.3.0)
Requires-Dist: unstructured-client (>=0.25.0,<0.26.0)
Requires-Dist: unstructured[all-docs] (>=0.15.7,<0.16.0) ; (python_version < "3.13") and (extra == "local")
Project-URL: Repository, https://github.com/langchain-ai/langchain
Project-URL: Release Notes, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-unstructured%3D%3D0%22&expanded=true
Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/partners/unstructured
Description-Content-Type: text/markdown

# langchain-unstructured

This package contains the LangChain integration with Unstructured

## Installation

```bash
pip install -U langchain-unstructured
```

And you should configure credentials by setting the following environment variables:

```bash
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:
```bash
    pip install -U langchain-unstructured
    pip install -U unstructured-client
    export UNSTRUCTURED_API_KEY="your-api-key"
```

Instantiate:
```python
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:
```python
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

