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/async_pg_vector.py
import asyncio
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
vector_db = PgVector(table_name="recipes", db_url=db_url)
knowledge_base = Knowledge(
vector_db=vector_db,
)
agent = Agent(knowledge=knowledge_base)
if __name__ == "__main__":
asyncio.run(
knowledge_base.ainsert(url="https://docs.agno.com/introduction/agents.md")
)
asyncio.run(
agent.aprint_response("What is the purpose of an Agno Agent?", markdown=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/async_pg_vector.py