Skip to main content

PGVector

Vector search in PostgreSQL using pgvector extension.

Setup

# Docker with pgvector
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=password ankane/pgvector

pip install psycopg2-binary

Quick Start (Agent with Knowledge)

Use PGVector as a knowledge store with an agent:
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant with access to documents.",
    knowledge=["./docs/guide.pdf"],
    knowledge_config={
        "vector_store": "pgvector",
        "url": "postgresql://postgres:password@localhost:5432/praisonai"
    }
)

agent.chat("What does the guide say?")

Advanced Usage (Direct Store)

from praisonai.persistence.factory import create_knowledge_store

store = create_knowledge_store(
    "pgvector",
    url="postgresql://postgres:password@localhost:5432/praisonai"
)

store.create_collection("documents", dimension=384)
store.insert("documents", [doc])
results = store.search("documents", query_embedding, limit=5)

Configuration

OptionDescription
urlPostgreSQL connection URL
schemaSchema name (default: public)
table_prefixTable prefix (default: praison_)