Firestore for Team
Kern supports using Firestore as a storage backend for Teams using the FirestoreDb class.
Usage
You need to provide a project_id parameter to the FirestoreDb class. Firestore will connect automatically using your Google Cloud credentials.
1"""2Run: `uv pip install openai newspaper4k lxml_html_clean kern-ai` to install the dependencies3"""45from typing import List67from kern.agent import Agent8from kern.db.firestore import FirestoreDb9from kern.models.openai import OpenAIResponses10from kern.team import Team11from kern.tools.hackernews import HackerNewsTools12from kern.tools.hackernews import HackerNewsTools13from pydantic import BaseModel1415# Setup the Firestore database16PROJECT_ID = "kern-os-test" # Use your project ID here17db = FirestoreDb(project_id=PROJECT_ID)1819class Article(BaseModel):20 title: str21 summary: str22 reference_links: List[str]2324hn_researcher = Agent(25 name="HackerNews Researcher",26 model=OpenAIResponses(id="gpt-5.2"),27 role="Gets top stories from hackernews.",28 tools=[HackerNewsTools()],29)3031web_searcher = Agent(32 name="Web Searcher",33 model=OpenAIResponses(id="gpt-5.2"),34 role="Searches the web for information on a topic",35 tools=[HackerNewsTools()],36 add_datetime_to_context=True,37)3839hn_team = Team(40 name="HackerNews Team",41 model=OpenAIResponses(id="gpt-5.2"),42 members=[hn_researcher, web_searcher],43 db=db,44 instructions=[45 "First, search hackernews for what the user is asking about.",46 "Then, ask the web searcher to search for each story to get more information.",47 "Finally, provide a thoughtful and engaging summary.",48 ],49 output_schema=Article,50 markdown=True,51 show_members_responses=True,52)5354hn_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_client | Optional[Client] | - | The Firestore client to use. |
project_id | Optional[str] | - | The GCP project ID for Firestore. |
session_collection | Optional[str] | - | Name of the collection to store sessions. |
memory_collection | Optional[str] | - | Name of the collection to store memories. |
metrics_collection | Optional[str] | - | Name of the collection to store metrics. |
eval_collection | Optional[str] | - | Name of the collection to store evaluation runs. |
knowledge_collection | Optional[str] | - | Name of the collection to store knowledge documents. |
traces_collection | Optional[str] | - | Name of the collection to store traces. |
spans_collection | Optional[str] | - | Name of the collection to store spans. |