Ollama with Reasoning Tools

Add the following code to your Python file

1from kern.agent import Agent
2from kern.models.ollama.chat import Ollama
3from kern.tools.hackernews import HackerNewsTools
4from kern.tools.reasoning import ReasoningTools
5
6reasoning_agent = Agent(
7 model=Ollama(id="llama3.2:latest"),
8 tools=[
9 ReasoningTools(
10 think=True,
11 analyze=True,
12 add_instructions=True,
13 add_few_shot=True,
14 ),
15 HackerNewsTools(),
16 ],
17 instructions="Use tables where possible",
18 markdown=True,
19)
20reasoning_agent.print_response(
21 "Write a report comparing NVDA to TSLA",
22 stream=True,
23 show_full_reasoning=True,
24)

Set up your virtual environment

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

Install dependencies

1uv pip install -U kern-ai ollama ddgs

Run Agent

1python ollama_reasoning_tools.py