forked from TaiToTo/EstonianCurriculumVisualizaitonDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
46 lines (33 loc) · 1.37 KB
/
test.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
import os
import json
import requests
from dotenv import load_dotenv
import weaviate
from weaviate.classes.init import Auth
from weaviate.classes.config import Configure
load_dotenv()
# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]
cohere_api_key = os.environ["COHERE_API_KEY"]
client = weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url, # Replace with your Weaviate Cloud URL
auth_credentials=Auth.api_key(weaviate_api_key), # Replace with your Weaviate Cloud key
headers={"X-Cohere-Api-Key": cohere_api_key}, # Replace with your Cohere API key
)
# resp = requests.get(
# "https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json"
# )
# data = json.loads(resp.text)
collections = client.collections.get("CurriculumDemo")
for item in collections.iterator():
if item.properties["paragraph_idx"] <= 10 and item.properties["subject"]=="language_and_literature":
print(item.properties)
# response = questions.generate.near_text(
# query="biology",
# limit=5,
# grouped_task="Write a tweet with emojis about these facts."
# )
# print(response.generated)
# print(response.objects[0].properties["question"])
client.close() # Free up resources