Skip to main content

Unstructured

This example covers how to use Unstructured to load files of many types. Unstructured currently supports loading of text files, powerpoints, html, pdfs, images, and more.

Setup

You can run Unstructured locally in your computer using Docker. To do so, you need to have Docker installed. You can find the instructions to install Docker here.

docker run -p 8000:8000 -d --rm --name unstructured-api quay.io/unstructured-io/unstructured-api:latest --port 8000 --host 0.0.0.0

Usage

Once Unstructured is running, you can use it to load files from your computer. You can use the following code to load a file from your computer.

import { UnstructuredLoader } from "langchain/document_loaders/fs/unstructured";

export const run = async () => {
const loader = new UnstructuredLoader(
"http://localhost:8000/general/v0/general",
"langchain/src/document_loaders/tests/example_data/example.txt"
);
const docs = await loader.load();
console.log({ docs });
};