Spaces:
Sleeping
Sleeping
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'] |