Singlestore for Agent

Kern supports using Singlestore as a storage backend for Agents using the SingleStoreDb class.

Usage

Obtain the credentials for Singlestore from here

1from os import getenv
2
3from kern.agent import Agent
4from kern.db.singlestore.singlestore import SingleStoreDb
5from kern.tools.hackernews import HackerNewsTools
6
7# Configure SingleStore DB connection
8USERNAME = getenv("SINGLESTORE_USERNAME")
9PASSWORD = getenv("SINGLESTORE_PASSWORD")
10HOST = getenv("SINGLESTORE_HOST")
11PORT = getenv("SINGLESTORE_PORT")
12DATABASE = getenv("SINGLESTORE_DATABASE")
13
14db_url = (
15 f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
16)
17
18db = SingleStoreDb(db_url=db_url)
19
20# Create an agent with SingleStore db
21agent = Agent(
22 db=db,
23 tools=[HackerNewsTools()],
24 add_history_to_context=True,
25)
26agent.print_response("How many people live in Canada?")
27agent.print_response("What is their national anthem called?")

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
db_engineOptional[Engine]-The SQLAlchemy database engine to use.
db_schemaOptional[str]-The database schema to use.
db_urlOptional[str]-The database URL to connect to.
session_tableOptional[str]-Name of the table to store Agent, Team and Workflow sessions.
memory_tableOptional[str]-Name of the table to store 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 content.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.