SurreabDB

Use SurrealDB for agent session storage.

Kern supports using SurreabDB as a database with the SurrealDb class.

You can get started with SurreabDB following their documentation.

Run SurreabDB locally with the following command:

1docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root

Usage

1from kern.agent import Agent
2from kern.db.surrealdb import SurrealDb
3
4# SurrealDB connection parameters
5SURREALDB_URL = "ws://localhost:8000"
6SURREALDB_USER = "root"
7SURREALDB_PASSWORD = "root"
8SURREALDB_NAMESPACE = "kern"
9SURREALDB_DATABASE = "surrealdb_for_agent"
10
11creds = {"username": SURREALDB_USER, "password": SURREALDB_PASSWORD}
12db = SurrealDb(None, SURREALDB_URL, creds, SURREALDB_NAMESPACE, SURREALDB_DATABASE)
13
14agent = Agent(db=db)

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
clientOptional[Union[BlockingWsSurrealConnection, BlockingHttpSurrealConnection]]-A blocking connection, either HTTP or WebSocket.
db_urlstr-The SurrealDB connection URL.
db_credsdict[str, str]-Database credentials dictionary (username, password).
db_nsstr-The SurrealDB namespace to use.
db_dbstr-The SurrealDB database name to use.
session_tableOptional[str]-Name of the table to store Agent, Team and Workflow sessions.
memory_tableOptional[str]-Name of the table to store user memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs data.
knowledge_tableOptional[str]-Name of the table to store knowledge documents data.
culture_tableOptional[str]-Name of the table to store cultural knowledge data.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.