Agent with Tools (Interactions)

Code

1import asyncio
2
3from kern.agent import Agent
4from kern.models.google import GeminiInteractions
5from kern.tools.websearch import WebSearchTools
6
7agent = Agent(
8 model=GeminiInteractions(id="gemini-3-flash-preview"),
9 tools=[WebSearchTools()],
10 markdown=True,
11)
12
13if __name__ == "__main__":
14 agent.print_response("Whats happening in France?")
15
16 agent.print_response("Whats happening in France?", stream=True)
17
18 asyncio.run(agent.aprint_response("Whats happening in France?", 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>=2.0" kern-ai

Run Agent

1python cookbook/90_models/google/gemini_interactions/tool_use.py