Spaces:
Build error
Build error
File size: 874 Bytes
ed8aec1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import weaviate
from weaviate.embedded import EmbeddedOptions
from weaviate import Client
def initialize_weaviate_client():
return weaviate.Client(embedded_options=EmbeddedOptions())
def class_exists(client, class_name):
try:
client.schema.get_class(class_name)
return True
except:
return False
def map_dtype_to_weaviate(dtype):
if "int" in str(dtype):
return "int"
elif "float" in str(dtype):
return "number"
elif "bool" in str(dtype):
return "boolean"
else:
return "string"
def ingest_data_to_weaviate(client, dataframe, class_name, class_description):
# ... [same as in your code]
def get_class_schema(client, class_name):
all_classes = client.schema.get()["classes"]
for cls in all_classes:
if cls["class"] == class_name:
return cls
return None
|