|
| 1 | +```bash Python Ingest v2 |
| 2 | +import os |
| 3 | + |
| 4 | +from unstructured_ingest.v2.pipeline.pipeline import Pipeline |
| 5 | +from unstructured_ingest.v2.interfaces import ProcessorConfig |
| 6 | + |
| 7 | +from unstructured_ingest.v2.processes.connectors.local import ( |
| 8 | + LocalIndexerConfig, |
| 9 | + LocalDownloaderConfig, |
| 10 | + LocalConnectionConfig |
| 11 | +) |
| 12 | + |
| 13 | +from unstructured_ingest.v2.processes.partitioner import PartitionerConfig |
| 14 | +from unstructured_ingest.v2.processes.chunker import ChunkerConfig |
| 15 | +from unstructured_ingest.v2.processes.embedder import EmbedderConfig |
| 16 | + |
| 17 | +from unstructured_ingest.v2.processes.connectors.onedrive import ( |
| 18 | + OnedriveConnectionConfig, |
| 19 | + OnedriveAccessConfig, |
| 20 | + OnedriveUploaderConfig |
| 21 | +) |
| 22 | + |
| 23 | +# Chunking and embedding are optional. |
| 24 | + |
| 25 | +if __name__ == "__main__": |
| 26 | + Pipeline.from_configs( |
| 27 | + context=ProcessorConfig(), |
| 28 | + indexer_config=LocalIndexerConfig(input_path=os.getenv("LOCAL_FILE_INPUT_DIR")), |
| 29 | + downloader_config=LocalDownloaderConfig(), |
| 30 | + source_connection_config=LocalConnectionConfig(), |
| 31 | + partitioner_config=PartitionerConfig( |
| 32 | + partition_by_api=True, |
| 33 | + api_key=os.getenv("UNSTRUCTURED_API_KEY"), |
| 34 | + partition_endpoint=os.getenv("UNSTRUCTURED_API_URL"), |
| 35 | + strategy="hi_res", |
| 36 | + additional_partition_args={ |
| 37 | + "split_pdf_page": True, |
| 38 | + "split_pdf_allow_failed": True, |
| 39 | + "split_pdf_concurrency_level": 15 |
| 40 | + } |
| 41 | + ), |
| 42 | + chunker_config=ChunkerConfig(chunking_strategy="by_title"), |
| 43 | + embedder_config=EmbedderConfig(embedding_provider="huggingface"), |
| 44 | + destination_connection_config=OnedriveConnectionConfig( |
| 45 | + access_config=OnedriveAccessConfig(client_cred=os.getenv("ONEDRIVE_CLIENT_CRED")), |
| 46 | + client_id=os.getenv("ONEDRIVE_CLIENT_ID"), |
| 47 | + user_pname=os.getenv("ONEDRIVE_USER_PNAME"), |
| 48 | + tenant=os.getenv("ONEDRIVE_TENANT"), |
| 49 | + authority_url=os.getenv("ONEDRIVE_AUTHORITY_URL") |
| 50 | + ), |
| 51 | + uploader_config=OnedriveUploaderConfig( |
| 52 | + remote_url=os.getenv("ONEDRIVE_PATH"), |
| 53 | + prefix="onedrive://" |
| 54 | + ) |
| 55 | + ).run() |
| 56 | +``` |
0 commit comments