Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 7.1 — Why Models Need Tools
LLM Engineering · Example 1 of 2

A model alone: confident and wrong

The fake model returns scripted answers, like a real model that has no tool: fluent text, no way to check it.

A model only produces text: it has no live data, it is unreliable at exact maths and it cannot act on the world. Tool calling lets the model ask for a function and lets your code run it, so the model supplies judgement and your code supplies facts and actions.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write parse_arguments(text) that returns the dict for a tool call's arguments string, or None when the text is not valid JSON or is not a JSON object.

02

Write make_tool_message(call, result) that returns the tool message dict for a tool call dict call (with an id) and a result string.

Explain it without notes

01

Why can't a model on its own tell you today's weather or multiply two five-digit numbers reliably?

02

Who actually runs a tool in function calling, and why does that matter for security?

03

What does the arguments field of a tool call contain, and what should your code do with it?

A model alone: confident and wrong
Sign in to run this example in your browser.

Expected output

model alone: 48271 * 91 = 4392000
real answer: 4392661
model is right: no
time question: It is 14:05 in Pune.
(the time was written in advance: no clock is connected)