Singlestore for Workflow
Kern supports using Singlestore as a storage backend for Workflows using the SingleStoreDb class.
Usage
Obtain the credentials for Singlestore from here
1from kern.agent import Agent2from kern.db.singlestore import SingleStoreDb3from kern.models.openai import OpenAIResponses4from kern.team import Team5from kern.tools.hackernews import HackerNewsTools6from kern.tools.hackernews import HackerNewsTools7from kern.workflow.step import Step8from kern.workflow.workflow import Workflow910# Configure SingleStore DB connection11USERNAME = getenv("SINGLESTORE_USERNAME")12PASSWORD = getenv("SINGLESTORE_PASSWORD")13HOST = getenv("SINGLESTORE_HOST")14PORT = getenv("SINGLESTORE_PORT")15DATABASE = getenv("SINGLESTORE_DATABASE")16SSL_CERT = getenv("SINGLESTORE_SSL_CERT", None)1718db_url = (19 f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"20)21db = SingleStoreDb(db_url=db_url)2223# Define agents24hackernews_agent = Agent(25 name="Hackernews Agent",26 model=OpenAIResponses(id="gpt-5.2"),27 tools=[HackerNewsTools()],28 role="Extract key insights and content from Hackernews posts",29)30web_agent = Agent(31 name="Web Agent",32 model=OpenAIResponses(id="gpt-5.2"),33 tools=[HackerNewsTools()],34 role="Search the web for the latest news and trends",35)3637# Define research team for complex analysis38research_team = Team(39 name="Research Team",40 members=[hackernews_agent, web_agent],41 instructions="Research tech topics from Hackernews and the web",42)4344content_planner = Agent(45 name="Content Planner",46 model=OpenAIResponses(id="gpt-5.2"),47 instructions=[48 "Plan a content schedule over 4 weeks for the provided topic and research content",49 "Ensure that I have posts for 3 posts per week",50 ],51)5253# Define steps54research_step = Step(55 name="Research Step",56 team=research_team,57)5859content_planning_step = Step(60 name="Content Planning Step",61 agent=content_planner,62)6364# Create and use workflow65if __name__ == "__main__":66 content_creation_workflow = Workflow(67 name="Content Creation Workflow",68 description="Automated content creation from blog posts to social media",69 db=db,70 steps=[research_step, content_planning_step],71 )72 content_creation_workflow.print_response(73 input="AI trends in 2024",74 markdown=True,75 )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. |