Documentation Index
Fetch the complete documentation index at: https://agno-v2-shaloo-ai-support-link.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Code
cookbook/08_knowledge/vector_db/pgvector/pgvector_hybrid_search.py
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.vectordb.pgvector import PgVector, SearchType
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
name="My PG Vector Knowledge Base",
description="This is a knowledge base that uses a PG Vector DB",
vector_db=PgVector(
table_name="vectors", db_url=db_url, search_type=SearchType.hybrid
),
)
knowledge.insert(
name="Recipes",
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
metadata={"doc_type": "recipe_book"},
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
knowledge=knowledge,
search_knowledge=True,
read_chat_history=True,
markdown=True,
)
agent.print_response(
"How do I make chicken and galangal in coconut milk soup", stream=True
)
agent.print_response("What was my last question?", stream=True)
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
Install dependencies
uv pip install -U psycopg2-binary pgvector pypdf openai agno
Create a file resources.py with the following contents:
from agno.docker.app.postgres import PgVectorDb
from agno.docker.resources import DockerResources
# -*- PgVector running on port 5432:5432
vector_db = PgVectorDb(
pg_user="ai",
pg_password="ai",
pg_database="ai",
debug_mode=True,
)
# -*- DockerResources
dev_docker_resources = DockerResources(apps=[vector_db])
Press Enter to confirm and verify container status on the docker dashboard.
Set environment variables
export OPENAI_API_KEY=xxx
Run Agent
python cookbook/08_knowledge/vector_db/pgvector/pgvector_hybrid_search.py