Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: What an LLM Is and Why Engineering Matters
LLM Engineering · Exercise 4 of 5 PreviousNext
Beginner

One retry, only for the right errors

Write call_with_one_retry(call). call is a function with no arguments that returns text or raises an error.

Call it. If it raises RateLimitError or TimeoutError, call it once more. If the second call also raises one of those, return "Sorry, try again later.". Any other error must not be retried: let it propagate.

What Check tests

  1. A successful call returns its text
  2. Retries once after a rate limit
  3. Two failures give the fallback message
  4. Other errors are not retried

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.