LLM Engineering · Exercise 1 of 6Next
Intermediate
Parse a tool call
A model returned a tool call. Write parse_call(call) that returns a tuple (name, args): the function name and the arguments as a dict (the arguments field is a JSON string).
If the string is not valid JSON, raise ValueError("arguments are not valid JSON"). If it is valid JSON but not an object, raise ValueError("arguments must be a JSON object").
What Check tests
- A valid call gives
(name, args) - Broken JSON raises
ValueError - Valid JSON that is not an object raises
ValueError - An empty object is fine
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.