SurrealDb is a class that implements the Db interface using SurrealDB as the backend storage system. It provides multi-modal storage for agent sessions with support for JSON data types and schema versioning.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
client | Optional[Union[BlockingWsSurrealConnection, BlockingHttpSurrealConnection]] | - | A blocking connection, either HTTP or WebSocket. |
db_url | str | - | The SurrealDB connection URL. |
db_creds | dict[str, str] | - | Database credentials dictionary (username, password). |
db_ns | str | - | The SurrealDB namespace to use. |
db_db | str | - | The SurrealDB database name to use. |
session_table | Optional[str] | - | Name of the table to store Agent, Team and Workflow sessions. |
memory_table | Optional[str] | - | Name of the table to store user memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs data. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge documents data. |
culture_table | Optional[str] | - | Name of the table to store cultural knowledge data. |
Methods
upsert_sessions
Bulk upsert multiple sessions for improved performance on large datasets.
Parameters:
sessions(List[Session]): List of sessions to upsertdeserialize(Optional[bool]): Whether to deserialize the sessions. Defaults toTrue
List[Union[Session, Dict[str, Any]]]
upsert_memories
Bulk upsert multiple memories for improved performance on large datasets.
Parameters:
memories(List[UserMemory]): List of memories to upsertdeserialize(Optional[bool]): Whether to deserialize the memories. Defaults toTrue
List[Union[UserMemory, Dict[str, Any]]]