JSON Files as Database
Use local JSON files for simple agent session storage.
Kern supports using local JSON files as a "database" with the JsonDb class.
This is a simple way to store your Agent's session data without having to setup a database.
Warning
Using JSON files as a database is not recommended for production applications. Use it for demos, testing and any other use case where you don't want to setup a database.
Usage
1from kern.agent import Agent2from kern.db.json import JsonDb34# Setup the JSON database5db = JsonDb(db_path="tmp/json_db")67# Setup your Agent with the Database8agent = Agent(db=db)Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_path | Optional[str] | - | Path to the directory where JSON files will be stored. |
session_table | Optional[str] | - | Name of the JSON file to store sessions (without .json extension). |
memory_table | Optional[str] | - | Name of the JSON file to store memories. |
metrics_table | Optional[str] | - | Name of the JSON file to store metrics. |
eval_table | Optional[str] | - | Name of the JSON file to store evaluation runs. |
knowledge_table | Optional[str] | - | Name of the JSON file to store knowledge content. |
traces_table | Optional[str] | - | Name of the JSON file to store traces. |
spans_table | Optional[str] | - | Name of the JSON file to store spans. |