-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_db.py
50 lines (45 loc) · 1.44 KB
/
setup_db.py
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
import utils
import weaviate.classes as wvc
import constants
import weaviate
client = utils.connect_db()
client.collections.delete(constants.RECIPE_TABLE_NAME)
try:
recipes = client.collections.create(
name = constants.RECIPE_TABLE_NAME,
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_voyageai(),
generative_config=wvc.config.Configure.Generative.cohere(),
properties=[
wvc.config.Property(
name="recipe_id",
data_type=wvc.config.DataType.TEXT,
),
wvc.config.Property(
name="minutes",
data_type=wvc.config.DataType.INT,
),
wvc.config.Property(
name="name",
data_type=wvc.config.DataType.TEXT,
),
wvc.config.Property(
name="nutrition",
data_type=wvc.config.DataType.TEXT,
),
wvc.config.Property(
name="steps",
data_type=wvc.config.DataType.TEXT,
),
wvc.config.Property(
name="description",
data_type=wvc.config.DataType.TEXT,
),
],
)
except weaviate.exceptions.UnexpectedStatusCodeError as e:
print("Table exists already. Skipping creation.")
print(e)
except Exception as e:
print("An error occurred while creating the table.")
print(e)
client.close()