/ examples / vector / weaviate_wow.py
weaviate_wow.py
 1  """Weaviate Cloud Vector Store - Agent-First Example
 2  
 3  Requires: export WEAVIATE_URL=... and WEAVIATE_API_KEY=...
 4  """
 5  import os
 6  import sys
 7  from praisonaiagents import Agent
 8  
 9  weaviate_url = os.getenv("WEAVIATE_URL", "https://your-cluster.weaviate.cloud")
10  weaviate_key = os.getenv("WEAVIATE_API_KEY")
11  if not weaviate_key:
12      print("SKIPPED: Weaviate - WEAVIATE_API_KEY not set")
13      sys.exit(0)
14  
15  # Agent-first approach: use knowledge parameter with Weaviate
16  agent = Agent(
17      name="Assistant",
18      instructions="You are a helpful assistant with access to documents.",
19      knowledge={
20          "sources": ["./docs/guide.pdf"],
21          "vector_store": "weaviate",
22          "url": weaviate_url,
23          "api_key": weaviate_key
24      }
25  )
26  
27  # Chat - agent uses knowledge for RAG
28  response = agent.chat("What information do you have?")
29  print(f"Response: {response}")
30  
31  print("PASSED: Weaviate with Agent")
32  
33  # --- Advanced: Direct Store Usage ---
34  # import weaviate
35  # from weaviate.classes.init import Auth
36  # client = weaviate.connect_to_weaviate_cloud(cluster_url=weaviate_url, auth_credentials=Auth.api_key(weaviate_key))