Give your offline AI real tools: live weather, your own notes and a calculator
Out of the box, the model on your laptop can't look anything up and gets sums wrong. Tool calling fixes that: you write small Python functions, the model asks to use them, and your code decides whether it can. Build a working agent with three tools and the guard rails that keep it in line.
agent.py) that lets your local model call tools in a loop until it has an answer- Guard rails you can test yourself: a tool allowlist, argument checks against the schema, a yes/no prompt before anything writes to disk, and a log of every call
- A starter kit with sample notes, so it works the moment you unzip it
- Ollama running with
gemma4:e2bdownloaded, from Run a ChatGPT-style AI on your own laptop. 16GB of RAM is comfortable; 8GB works but is slow. Gemma 4 needs Ollama 0.20.7 or newer: check withollama --version. - uv, the Python tool from Put AI in your terminal. It fetches Python and the
ollamalibrary for you, so you don't install anything by hand. - An internet connection for the weather tool only. The model, your notes and the calculator all stay on your PC.
- Comfort with the terminal:
cd, running a command, reading an error. If that's new, do the Terminal survival kit first.
Check your model can use tools
Only some models are trained to ask for tools. Check yours is one of them before writing any code.
A language model can only produce text. It can't open a file, fetch a web page or reliably multiply two numbers. Tool calling (also called function calling) gets round that. You describe some tools to the model. When a question needs one, the model replies with a structured request instead of an answer: the tool's name and the arguments to use. Your program runs the tool and hands the result back. The model never runs anything itself.
That only works if the model was trained for it. Start Ollama (from the Start menu or Applications; on Linux it already runs as a background service), then check what you've got:
Terminalollama list ollama show gemma4:e2bollama showprints a Capabilities section. You're looking fortoolsin it. Gemma 4 has it, along withthinkingandvision. Ollama tags every model that supports this, so you can browse them all at ollama.com/search?c=tools ↗.- `gemma4:e2b` (4.6GB): the model from the earlier lessons. It's the default in this kit.
- `qwen3:4b` (2.5GB): a good second choice. Qwen 3 is the model Ollama uses in its own tool calling docs ↗. Get it with
ollama pull qwen3:4bif Gemma struggles.
Last, make sure uv is there. It runs the Python files in this mission and installs what they need on the fly:
Terminaluv --versionWindows (only if uv is missing)winget install --id astral-sh.uv -eMac (only if uv is missing)brew install uvLinux, or Mac without Homebrew (only if uv is missing)curl -LsSf https://astral.sh/uv/install.sh | sh
ollama show gemma4:e2b lists tools under Capabilities, and uv --version prints a version number.If it breaks'could not connect to a running Ollama instance' + 2 more
'could not connect to a running Ollama instance'
ollama serve in another terminal window.There's no tools in the Capabilities list
ollama pull qwen3:4b, and use that name everywhere this mission says gemma4:e2b.'uv' is not recognised
uv by its full path once and then uv tool update-shell, or restart the PC.