MediaSearch / weaviate_explorer.py
azamat's picture
Init
a20be5b
raw
history blame
554 Bytes
import os
import weaviate
class WeaviateExplorer:
def __init__(self):
self.client = weaviate.Client(
url = os.getenv("WEAVIATE_CLUSTER_URL"),
auth_client_secret=weaviate.auth.AuthApiKey(api_key=os.getenv("WEAVIATE_API_KEY"))
)
def explore(self, query):
response = (
self.client.query
.get("Short", ["title", "link"])
.with_near_text({"concepts": [query]})
.with_limit(5)
.do()
)
return response['data']['Get']['Short']