phidatahq / phidata

Build AI Agents with memory, knowledge, tools and reasoning. Chat with them using a beautiful Agent UI.
https://docs.phidata.com
Mozilla Public License 2.0
15.58k stars 2.14k forks source link

Weaviate Vectordb implementation #1336

Open rohinish404 opened 1 month ago

rohinish404 commented 1 month ago

Issue #1324

rohinish404 commented 3 weeks ago

@manthanguptaa I have few doubts -

Best practice: store your credentials in environment variables

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

manthanguptaa commented 3 weeks ago

Hey @rohinish404, can you add a cookbook for this example? It will help me test it and also help you with your doubts.

manthanguptaa commented 1 week ago

@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

manthanguptaa commented 1 week ago

And as for insertion. Give option to allow user to have batch inserts as well as single inserts

manthanguptaa commented 4 days ago

Hey @rohinish404 are you working on this?