Open rohinish404 opened 1 month ago
@manthanguptaa I have few doubts -
import weaviate
from weaviate.classes.init import Auth
import requests, json, os
wcd_url = os.environ["WCD_URL"] wcd_api_key = os.environ["WCD_API_KEY"] openai_api_key = os.environ["OPENAI_APIKEY"]
client = weaviate.connect_to_weaviate_cloud( cluster_url=wcd_url, # Replace with your Weaviate Cloud URL auth_credentials=Auth.api_key(wcd_api_key), # Replace with your Weaviate Cloud key headers={"X-OpenAI-Api-Key": openai_api_key}, # Replace with your OpenAI API key )
resp = requests.get( "https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json" ) data = json.loads(resp.text)
questions = client.collections.get("Question")
with questions.batch.dynamic() as batch: for d in data: batch.add_object({ "answer": d["Answer"], "question": d["Question"], "category": d["Category"], })
client.close() # Free up resources
Hey @rohinish404, can you add a cookbook for this example? It will help me test it and also help you with your doubts.
@rohinish404 just looked at connections for weaviate. Support cloud and local for now. Let's hold off on the custom connection. Take the URL, API key, host, port, and grpc_port in the class. Check what params are provided and connect accordingly. Throw error accordingly as well
And as for insertion. Give option to allow user to have batch inserts as well as single inserts
Hey @rohinish404 are you working on this?
Issue #1324