Flash Thinking Agent

Code

1from kern.agent import Agent
2from kern.models.google import Gemini
3
4task = (
5 "Three missionaries and three cannibals need to cross a river. "
6 "They have a boat that can carry up to two people at a time. "
7 "If, at any time, the cannibals outnumber the missionaries on either side of the river, the cannibals will eat the missionaries. "
8 "How can all six people get across the river safely? Provide a step-by-step solution and show the solutions as an ascii diagram"
9)
10
11agent = Agent(model=Gemini(id="gemini-2.0-flash-thinking-exp-1219"), markdown=True)
12agent.print_response(task, stream=True)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U google-genai kern-ai

Run Agent

1python cookbook/11_models/google/gemini/flash_thinking_agent.py