Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Answer questions from a PDF using an OpenAI agent and PgVector.
from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.models.openai import OpenAIChat from agno.vectordb.pgvector import PgVector db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" knowledge = Knowledge( vector_db=PgVector(table_name="recipes", db_url=db_url), ) # Add content to the knowledge knowledge.insert(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf") agent = Agent(model=OpenAIChat(id="gpt-4o"), knowledge=knowledge) agent.print_response("How to make Thai curry?", markdown=True)
Set up your virtual environment
uv venv --python 3.12 source .venv/bin/activate
uv venv --python 3.12 .venv\Scripts\activate
Set your API key
export OPENAI_API_KEY=xxx
Install dependencies
uv pip install -U openai sqlalchemy psycopg pgvector pypdf agno
Run PgVector
docker run -d \ -e POSTGRES_DB=ai \ -e POSTGRES_USER=ai \ -e POSTGRES_PASSWORD=ai \ -e PGDATA=/var/lib/postgresql \ -v pgvolume:/var/lib/postgresql \ -p 5532:5432 \ --name pgvector \ agnohq/pgvector:18
Run Agent
knowledge.py
python knowledge.py
Was this page helpful?