Spaces:
Runtime error
Runtime error
File size: 3,027 Bytes
c5ac282 930acae c5ac282 930acae c5ac282 |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
import os
from dotenv import load_dotenv
import weaviate.classes as wvcc
import weaviate
from weaviate.classes.config import Property, DataType
import weaviate.classes as wvc
load_dotenv()
def init_client():
"""connects to data base
source: https://weaviate.io/developers/weaviate/tutorials/connect
"""
client = weaviate.connect_to_wcs(
cluster_url=os.getenv("YOUR_WCS_URL"), # Set this environment variable
auth_credentials=weaviate.auth.AuthApiKey(
os.getenv("YOUR_WCS_AUTH_KEY")
), # Set this environment variable
)
return client
x = 0
try:
client = init_client()
client.collections.create(
name="Component",
description="Component of a given Apparatus",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
properties=[
# wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
wvc.config.Property(name="UsedInComps", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="FeildsOfStudy", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="ToolName", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="Tags", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="GlbBlob", data_type=wvc.config.DataType.BLOB),
]
)
finally:
client.close()
try:
client = init_client()
client.collections.create(
name="ScienceEperiment",
description="Science Experiment with the goal of making something",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
properties=[
# wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
wvc.config.Property(name="UsedInComps", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="FeildsOfStudy", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="ToolName", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="Tags", data_type=wvc.config.DataType.TEXT_ARRAY),
]
)
finally:
client.close()
try:
client = init_client()
client.collections.create(
name="ComponentImage",
description="An image to gain visual context on a component",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
properties=[
# wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
wvc.config.Property(name="ImageContent", data_type=wvc.config.DataType.BLOB),
wvc.config.Property(name="ImageAngle", data_type=wvc.config.DataType.TEXT_ARRAY),
wvc.config.Property(name="BelongsToComponent", data_type=wvc.config.DataType.UUID),
]
)
finally:
client.close()
def main():
pass
if __name__ == '__main__':
x = 0 |