mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-07-04 15:42:16 +00:00
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import os
|
|
|
|
from unstructured.ingest.connector.fsspec.box import (
|
|
BoxAccessConfig,
|
|
BoxWriteConfig,
|
|
SimpleBoxConfig,
|
|
)
|
|
from unstructured.ingest.connector.local import SimpleLocalConfig
|
|
from unstructured.ingest.interfaces import (
|
|
ChunkingConfig,
|
|
EmbeddingConfig,
|
|
PartitionConfig,
|
|
ProcessorConfig,
|
|
ReadConfig,
|
|
)
|
|
from unstructured.ingest.runner import LocalRunner
|
|
from unstructured.ingest.runner.writers.base_writer import Writer
|
|
from unstructured.ingest.runner.writers.fsspec.box import (
|
|
BoxWriter,
|
|
)
|
|
|
|
|
|
def get_writer() -> Writer:
|
|
return BoxWriter(
|
|
connector_config=SimpleBoxConfig(
|
|
access_config=BoxAccessConfig(box_app_config=os.getenv("BOX_APP_CONFIG_PATH")),
|
|
remote_url="box://unstructured/war-and-peace-output",
|
|
),
|
|
write_config=BoxWriteConfig(),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
writer = get_writer()
|
|
runner = LocalRunner(
|
|
processor_config=ProcessorConfig(
|
|
verbose=True,
|
|
output_dir="local-output-to-box",
|
|
num_processes=2,
|
|
),
|
|
connector_config=SimpleLocalConfig(
|
|
input_path="example-docs/book-war-and-peace-1225p.txt",
|
|
),
|
|
read_config=ReadConfig(),
|
|
partition_config=PartitionConfig(),
|
|
chunking_config=ChunkingConfig(chunk_elements=True),
|
|
embedding_config=EmbeddingConfig(
|
|
provider="langchain-huggingface",
|
|
),
|
|
writer=writer,
|
|
writer_kwargs={},
|
|
)
|
|
runner.run()
|