Reasoning Agent

Code

1from kern.agent import Agent
2from kern.models.groq import Groq
3
4# Create a reasoning agent that uses:
5# - `deepseek-r1-distill-llama-70b` as the reasoning model
6# - `llama-3.3-70b-versatile` to generate the final response
7reasoning_agent = Agent(
8 model=Groq(id="llama-3.3-70b-versatile"),
9 reasoning_model=Groq(
10 id="deepseek-r1-distill-llama-70b", temperature=0.6, max_tokens=1024, top_p=0.95
11 ),
12)
13
14# Prompt the agent to solve the problem
15reasoning_agent.print_response("Is 9.11 bigger or 9.9?", 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 GROQ_API_KEY=xxx

Install dependencies

1uv pip install -U groq kern-ai

Run Agent

1python cookbook/11_models/groq/reasoning_agent.py