mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-07-03 23:20:35 +00:00

Closes #1781. - Adds a Weaviate destination connector - The connector receives a host for the weaviate instance and a weaviate class name. - Defines a weaviate schema for json elements. - Defines the pre-processing to conform unstructured's schema to the proposed weaviate schema.
22 lines
485 B
Python
Executable File
22 lines
485 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import json
|
|
import os
|
|
|
|
import weaviate
|
|
|
|
weaviate_host_url = os.getenv("WEAVIATE_HOST_URL", "http://localhost:8080")
|
|
class_name = os.getenv("WEAVIATE_CLASS_NAME", "Elements")
|
|
new_class = None
|
|
|
|
with open("./scripts/weaviate-test-helpers/elements.json") as f:
|
|
new_class = json.load(f)
|
|
|
|
client = weaviate.Client(
|
|
url=weaviate_host_url,
|
|
)
|
|
|
|
if client.schema.exists(class_name):
|
|
client.schema.delete_class(class_name)
|
|
client.schema.create_class(new_class)
|