isayahc commited on
Commit
c5ac282
1 Parent(s): d553a59

created the collection for the project

Browse files
Files changed (1) hide show
  1. weaviate_utils.py +85 -0
weaviate_utils.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+
4
+ import weaviate.classes as wvcc
5
+ import weaviate
6
+ from weaviate.classes.config import Property, DataType
7
+ import weaviate.classes as wvc
8
+
9
+ load_dotenv()
10
+
11
+
12
+ def init_client():
13
+ """connects to data base
14
+ source: https://weaviate.io/developers/weaviate/tutorials/connect
15
+ """
16
+ client = weaviate.connect_to_wcs(
17
+ cluster_url=os.getenv("YOUR_WCS_URL"), # Set this environment variable
18
+ auth_credentials=weaviate.auth.AuthApiKey(
19
+ os.getenv("YOUR_WCS_AUTH_KEY")
20
+ ), # Set this environment variable
21
+ )
22
+ return client
23
+
24
+
25
+
26
+ try:
27
+ client = init_client()
28
+ client.collections.create(
29
+ name="Component",
30
+ description="Component of a given Apparatus",
31
+ vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
32
+ properties=[
33
+ # wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
34
+ wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
35
+ wvc.config.Property(name="UsedInComps", data_type=wvc.config.DataType.TEXT_ARRAY),
36
+ wvc.config.Property(name="FeildsOfStudy", data_type=wvc.config.DataType.TEXT_ARRAY),
37
+ wvc.config.Property(name="ToolName", data_type=wvc.config.DataType.TEXT),
38
+ wvc.config.Property(name="Tags", data_type=wvc.config.DataType.TEXT_ARRAY),
39
+ ]
40
+ )
41
+ finally:
42
+ client.close()
43
+
44
+ try:
45
+ client = init_client()
46
+ client.collections.create(
47
+ name="ScienceEperiment",
48
+ description="Science Experiment with the goal of making something",
49
+ vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
50
+ properties=[
51
+ # wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
52
+ wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
53
+ wvc.config.Property(name="UsedInComps", data_type=wvc.config.DataType.TEXT_ARRAY),
54
+ wvc.config.Property(name="FeildsOfStudy", data_type=wvc.config.DataType.TEXT_ARRAY),
55
+ wvc.config.Property(name="ToolName", data_type=wvc.config.DataType.TEXT),
56
+ wvc.config.Property(name="Tags", data_type=wvc.config.DataType.TEXT_ARRAY),
57
+ ]
58
+ )
59
+ finally:
60
+ client.close()
61
+
62
+ try:
63
+ client = init_client()
64
+ client.collections.create(
65
+ name="ComponentImage",
66
+ description="An image to gain visual context on a component",
67
+ vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
68
+ properties=[
69
+ # wvc.config.Property(name="id", data_type=wvc.config.DataType.UUID),
70
+ wvc.config.Property(name="DateCreated", data_type=wvc.config.DataType.DATE),
71
+ wvc.config.Property(name="ImageContent", data_type=wvc.config.DataType.BLOB),
72
+ wvc.config.Property(name="ImageAngle", data_type=wvc.config.DataType.TEXT_ARRAY),
73
+ wvc.config.Property(name="BelongsToComponent", data_type=wvc.config.DataType.UUID),
74
+ ]
75
+ )
76
+ finally:
77
+ client.close()
78
+
79
+
80
+
81
+ def main():
82
+ pass
83
+
84
+ if __name__ == '__main__':
85
+ x = 0