Zack Saadioui
8/24/2024
1
2
bash
pip install --upgrade langchain-unstructured unstructured-client unstructured
1
2
3
4
python
import getpass
import os
os.environ["UNSTRUCTURED_API_KEY"] = getpass.getpass("Enter Unstructured API key: ")
1
2
python
from langchain_community.document_loaders import UnstructuredFileLoader
1
2
3
python
file_paths = ["./example_data/sample.txt"]
loader = UnstructuredFileLoader(file_paths)
1
2
python
docs = loader.load()
1
2
3
4
python
for doc in docs:
print("Content:", doc.page_content)
print("Metadata:", doc.metadata)
1 2 3 4
pages = [] for doc in loader.lazy_load(): pages.append(doc) print("Lazy Loaded Content:", doc.page_content)
Copyright © Arsturn 2024