Exercise 9 of 10 · 0 passed
Human-in-the-Loop
AI classifications aren't always right. When the model is confident, auto-accept. When it's not, ask the human.
This pattern:
- Check the confidence score against a threshold
- High confidence → accept automatically
- Low confidence → show the suggestion, let the user confirm or override
Why care? HITL is the difference between a trusted AI assistant and one that silently makes mistakes. The cohort's Telegram bot uses this exact flow — high confidence auto-files, low confidence sends an inline keyboard for human review.
Task
Complete process_with_hitl(result, threshold):
- If
confidence >= threshold, return the category directly - Otherwise print the low-confidence result and prompt the user
- Prompt:
f"Accept '{result.category}'? (Enter to confirm, or type a category): " - Empty input or
"y"→ return the suggested category - Anything else → return the user's input as the category
- Prompt:
Click "Run tests". First time loads Python in your browser (~5s). After that, runs are instant on this page and ~1s on the others.
Loading tests…
Pass the tests to reveal the reference solution.
The point of the exercise is the struggle, not the answer. Once your tests are green, the reference solution unlocks here so you can compare patterns.
Loading solution…
That's the warm-up.
You ran ten exercises against a mocked SDK. The cohort builds the real thing: an AI agent shipped to production with 150+ passing tests, Telegram bot, FastAPI, Streamlit, Docker. Six weeks. Every PR reviewed.