-
Notifications
You must be signed in to change notification settings - Fork 36
/
delete_card_schema.py
43 lines (31 loc) · 1.1 KB
/
delete_card_schema.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
import weaviate # type: ignore[import]
import typer
import os
from wasabi import msg # type: ignore[import]
from dotenv import load_dotenv
load_dotenv("../.env")
def main() -> None:
msg.divider("Starting schema creation")
# Connect to Weaviate
url = os.environ.get("WEAVIATE_URL", "")
openai_key = os.environ.get("OPENAI_API_KEY", "")
auth_config = weaviate.AuthApiKey(api_key=os.environ.get("WEAVIATE_API_KEY", ""))
if openai_key == "" or url == "":
msg.fail("Environment Variables not set.")
msg.warn(f"URL: {url}")
msg.warn(f"OPENAI API KEY: {openai_key}")
return
client = weaviate.Client(
url=url,
additional_headers={"X-OpenAI-Api-Key": openai_key},
auth_client_secret=auth_config,
)
msg.good("Client connected to Weaviate Server")
if not client.schema.exists("MagicChat_Card"):
msg.warn(f"MagicChat_Card class does not exist")
return
else:
client.schema.delete_class("MagicChat_Card")
msg.good(f"MagicChat_Card class deleted")
if __name__ == "__main__":
typer.run(main)