The PgVector Agent uses PgVector as Knowledge Base and Storage for the Agent.
from phi.agent import Agent
from phi.storage.agent.postgres import PgAgentStorage
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
agent = Agent(
storage=PgAgentStorage(table_name="recipe_agent", db_url=db_url),
knowledge_base=PDFUrlKnowledgeBase(
urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=PgVector(table_name="recipe_documents", db_url=db_url),
),
show_tool_calls=True,
search_knowledge=True,
read_chat_history=True,
)
agent.knowledge_base.load(recreate=False)
agent.print_response("How do I make pad thai?", markdown=True)