Memory with SQLite

Code

1from kern.agent import Agent
2from kern.db.sqlite import SqliteDb
3
4# Setup the SQLite database
5db = SqliteDb(db_file="tmp/data.db")
6
7# Setup a basic agent with the SQLite database
8agent = Agent(
9 db=db,
10 update_memory_on_run=True,
11)
12
13agent.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.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set environment variables

1export OPENAI_API_KEY=xxx

Install dependencies

1uv pip install -U kern-ai openai

Run Example

1python mem-sqlite-memory.py
1python mem-sqlite-memory.py