Selecting Custom Table Names

Kern allows you to customize table names when using databases, providing flexibility in organizing your data storage.

Usage

Specify custom table names when initializing your database connection.

1from kern.agent import Agent
2from kern.db.sqlite import SqliteDb
3
4# Setup the SQLite database with custom table names
5db = SqliteDb(
6 db_file="tmp/data.db",
7 # Selecting which tables to use
8 session_table="agent_sessions",
9 memory_table="agent_memories",
10 metrics_table="agent_metrics",
11)
12
13# Setup a basic agent with the SQLite database
14agent = Agent(
15 db=db,
16 update_memory_on_run=True,
17 add_history_to_context=True,
18 add_datetime_to_context=True,
19)
20
21# The Agent sessions and runs will now be stored in SQLite with custom table names
22agent.print_response("How many people live in Canada?")
23agent.print_response("And in Mexico?")
24agent.print_response("List my messages one by one")