-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathpgvector_real_wow.py
More file actions
27 lines (21 loc) · 901 Bytes
/
pgvector_real_wow.py
File metadata and controls
27 lines (21 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""PGVector Vector Store - Agent-First Example
Docker: docker run -d --name pgvector -e POSTGRES_PASSWORD=postgres -p 5433:5432 pgvector/pgvector:pg16
"""
import os
from praisonaiagents import Agent
url = os.getenv("PGVECTOR_URL", "postgresql://postgres:postgres@localhost:5433/postgres")
# Agent-first approach: use knowledge parameter with PGVector
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant with access to documents.",
knowledge={"sources": ["./docs/guide.pdf"], "vector_store": {"provider": "pgvector", "url": url}}
)
# Chat - agent uses knowledge for RAG
response = agent.chat("What information do you have?")
print(f"Response: {response}")
print("PASSED: PGVector with Agent")
# --- Advanced: Direct PGVector Usage ---
# import psycopg2
# conn = psycopg2.connect(url)
# cur = conn.cursor()
# cur.execute("CREATE EXTENSION IF NOT EXISTS vector")