Memory with PostgreSQL
Code
1from kern.agent import Agent2from kern.db.postgres import PostgresDb34# Setup Postgres5db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"6db = PostgresDb(db_url=db_url)78agent = Agent(9 db=db,10 update_memory_on_run=True,11)1213agent.print_response("My name is John Doe and I like to play basketball on the weekends.")14agent.print_response("What's do I do in weekends?")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet environment variables
1export OPENAI_API_KEY=xxxInstall dependencies
1uv pip install -U kern-ai openai sqlalchemy 'psycopg[binary]'Run Example
1python mem-postgres-memory.py1python mem-postgres-memory.py