Firestore for Workflows
Kern supports using Firestore as a storage backend for Workflows 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.
1from kern.agent import Agent2from kern.db.firestore import FirestoreDb3from 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 Workflow910PROJECT_ID = "kern-os-test" # Use your project ID here1112# Setup the Firestore database13db = FirestoreDb(project_id=PROJECT_ID)1415# Define agents16hackernews_agent = Agent(17 name="Hackernews Agent",18 model=OpenAIResponses(id="gpt-5.2"),19 tools=[HackerNewsTools()],20 role="Extract key insights and content from Hackernews posts",21)22web_agent = Agent(23 name="Web Agent",24 model=OpenAIResponses(id="gpt-5.2"),25 tools=[HackerNewsTools()],26 role="Search the web for the latest news and trends",27)2829# Define research team for complex analysis30research_team = Team(31 name="Research Team",32 members=[hackernews_agent, web_agent],33 instructions="Research tech topics from Hackernews and the web",34)3536content_planner = Agent(37 name="Content Planner",38 model=OpenAIResponses(id="gpt-5.2"),39 instructions=[40 "Plan a content schedule over 4 weeks for the provided topic and research content",41 "Ensure that I have posts for 3 posts per week",42 ],43)4445# Define steps46research_step = Step(47 name="Research Step",48 team=research_team,49)5051content_planning_step = Step(52 name="Content Planning Step",53 agent=content_planner,54)5556# Create and use workflow57if __name__ == "__main__":58 content_creation_workflow = Workflow(59 name="Content Creation Workflow",60 description="Automated content creation from blog posts to social media",61 db=db,62 steps=[research_step, content_planning_step],63 )64 content_creation_workflow.print_response(65 input="AI trends in 2024",66 markdown=True,67 )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. |