from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.knowledge import Knowledge
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.learn import LearningMachine, LearnedKnowledgeConfig
from agno.models.openai import OpenAIResponses
from agno.vectordb.pgvector import PgVector, SearchType
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
vector_db=PgVector(
db_url=db_url,
table_name="learned_knowledge",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=PostgresDb(db_url=db_url),
learning=LearningMachine(
knowledge=knowledge,
learned_knowledge=True,
),
)
# Agent can save insights
agent.print_response(
"Save this: When comparing cloud providers, always check egress costs first - "
"they can be 10x different between providers.",
user_id="alice@example.com",
)
# Agent automatically searches and applies relevant knowledge
agent.print_response(
"I'm choosing between AWS and GCP for our data platform. What should I consider?",
user_id="bob@example.com",
)