|
| 1 | +```python 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.vectara import ( |
| 8 | + VectaraAccessConfig, |
| 9 | + VectaraConnectionConfig, |
| 10 | + VectaraUploadStagerConfig, |
| 11 | + VectaraUploaderConfig |
| 12 | +) |
| 13 | +from unstructured_ingest.v2.processes.connectors.local import ( |
| 14 | + LocalIndexerConfig, |
| 15 | + LocalConnectionConfig, |
| 16 | + LocalDownloaderConfig |
| 17 | +) |
| 18 | +from unstructured_ingest.v2.processes.partitioner import PartitionerConfig |
| 19 | +from unstructured_ingest.v2.processes.chunker import ChunkerConfig |
| 20 | +from unstructured_ingest.v2.processes.embedder import EmbedderConfig |
| 21 | + |
| 22 | +# Chunking and embedding is optional. |
| 23 | + |
| 24 | +if __name__ == "__main__": |
| 25 | + Pipeline.from_configs( |
| 26 | + context=ProcessorConfig(), |
| 27 | + indexer_config=LocalIndexerConfig(input_path=os.getenv("LOCAL_FILE_INPUT_DIR")), |
| 28 | + downloader_config=LocalDownloaderConfig(), |
| 29 | + source_connection_config=LocalConnectionConfig(), |
| 30 | + partitioner_config=PartitionerConfig( |
| 31 | + partition_by_api=True, |
| 32 | + api_key=os.getenv("UNSTRUCTURED_API_KEY"), |
| 33 | + partition_endpoint=os.getenv("UNSTRUCTURED_API_URL"), |
| 34 | + additional_partition_args={ |
| 35 | + "split_pdf_page": True, |
| 36 | + "split_pdf_allow_failed": True, |
| 37 | + "split_pdf_concurrency_level": 15 |
| 38 | + } |
| 39 | + ), |
| 40 | + chunker_config=ChunkerConfig(chunking_strategy="by_title"), |
| 41 | + embedder_config=EmbedderConfig(embedding_provider="huggingface"), |
| 42 | + destination_connection_config=VectaraConnectionConfig( |
| 43 | + access_config=VectaraAccessConfig( |
| 44 | + oauth_client_id=os.getenv("VECTARA_OAUTH_CLIENT_ID"), |
| 45 | + oauth_secret=os.getenv("VECTARA_OAUTH_CLIENT_SECRET") |
| 46 | + ), |
| 47 | + customer_id=os.getenv("VECTARA_CUSTOMER_ID"), |
| 48 | + corpus_name=os.getenv("VECTARA_CORPUS_NAME"), |
| 49 | + corpus_key=os.getenv("VECTARA_CORPUS_KEY"), |
| 50 | + token_url=os.getenv("VECTARA_OAUTH_TOKEN_URL") |
| 51 | + ), |
| 52 | + stager_config=VectaraUploadStagerConfig(), |
| 53 | + uploader_config=VectaraUploaderConfig() |
| 54 | + ).run() |
| 55 | +``` |
0 commit comments