Singlestore for Team
Kern supports using Singlestore as a storage backend for Teams using the SingleStoreDb class.
Usage
Obtain the credentials for Singlestore from here
1"""2Run: `uv pip install openai newspaper4k lxml_html_clean kern-ai` to install the dependencies3"""4from os import getenv5from typing import List67from kern.agent import Agent8from kern.db.singlestore.singlestore import SingleStoreDb9from kern.models.openai import OpenAIResponses10from kern.team import Team11from kern.tools.hackernews import HackerNewsTools12from kern.tools.hackernews import HackerNewsTools13from pydantic import BaseModel1415# Configure SingleStore DB connection16USERNAME = getenv("SINGLESTORE_USERNAME")17PASSWORD = getenv("SINGLESTORE_PASSWORD")18HOST = getenv("SINGLESTORE_HOST")19PORT = getenv("SINGLESTORE_PORT")20DATABASE = getenv("SINGLESTORE_DATABASE")21SSL_CERT = getenv("SINGLESTORE_SSL_CERT", None)2223db_url = (24 f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"25)26db = SingleStoreDb(db_url=db_url)2728class Article(BaseModel):29 title: str30 summary: str31 reference_links: List[str]3233hn_researcher = Agent(34 name="HackerNews Researcher",35 model=OpenAIResponses(id="gpt-5.2"),36 role="Gets top stories from hackernews.",37 tools=[HackerNewsTools()],38)3940web_searcher = Agent(41 name="Web Searcher",42 model=OpenAIResponses(id="gpt-5.2"),43 role="Searches the web for information on a topic",44 tools=[HackerNewsTools()],45 add_datetime_to_context=True,46)4748hn_team = Team(49 name="HackerNews Team",50 model=OpenAIResponses(id="gpt-5.2"),51 members=[hn_researcher, web_searcher],52 db=db,53 instructions=[54 "First, search hackernews for what the user is asking about.",55 "Then, ask the web searcher to search for each story to get more information.",56 "Finally, provide a thoughtful and engaging summary.",57 ],58 output_schema=Article,59 markdown=True,60 show_members_responses=True,61)6263hn_team.print_response("Write an article about the top 2 stories on hackernews")Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_engine | Optional[Engine] | - | The SQLAlchemy database engine to use. |
db_schema | Optional[str] | - | The database schema to use. |
db_url | Optional[str] | - | The database URL to connect to. |
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 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 content. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |