promptdojo_

Routing — pick the path before doing the work — step 8 of 9

Build a full router. Write route(question) that:

  • Calls fake_classifier(question) to get a raw category string.
  • Normalizes it: .strip().lower().
  • If the normalized category is in ROUTES, run that handler with the question.
  • Otherwise run ROUTES["general"] as the fallback.
  • Returns the handler's output.

The classifier may return messy strings ("Billing", " general ", "unknown_category"). Your router should handle all three.

Then the script will run four cases. Expected output:

BILL -> I want a refund
TECH -> 500 error on checkout
GEN  -> what time do you open
GEN  -> something completely off-topic

full-screen editor opens — close anytime to keep reading.