Sqlite for Team
Kern supports using Sqlite as a storage backend for Teams using the SqliteDb class.
Usage
You need to provide either db_url, db_file or db_engine. The following example uses db_file.
1"""2Run: `uv pip install openai newspaper4k lxml_html_clean kern-ai` to install the dependencies3"""4from typing import List56from kern.agent import Agent7from kern.db.sqlite import SqliteDb8from kern.models.openai import OpenAIResponses9from kern.team import Team10from kern.tools.hackernews import HackerNewsTools11from kern.tools.hackernews import HackerNewsTools12from pydantic import BaseModel1314db = SqliteDb(db_file="tmp/data.db")1516class Article(BaseModel):17 title: str18 summary: str19 reference_links: List[str]2021hn_researcher = Agent(22 name="HackerNews Researcher",23 model=OpenAIResponses(id="gpt-5.2"),24 role="Gets top stories from hackernews.",25 tools=[HackerNewsTools()],26)2728web_searcher = Agent(29 name="Web Searcher",30 model=OpenAIResponses(id="gpt-5.2"),31 role="Searches the web for information on a topic",32 tools=[HackerNewsTools()],33 add_datetime_to_context=True,34)3536hn_team = Team(37 name="HackerNews Team",38 model=OpenAIResponses(id="gpt-5.2"),39 members=[hn_researcher, web_searcher],40 db=db,41 instructions=[42 "First, search hackernews for what the user is asking about.",43 "Then, ask the web searcher to search for each story to get more information.",44 "Finally, provide a thoughtful and engaging summary.",45 ],46 output_schema=Article,47 markdown=True,48 show_members_responses=True,49)5051hn_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_url | Optional[str] | - | The database URL to connect to. |
db_file | Optional[str] | - | The database file 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 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. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |