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
⌘↵ runs the editor.read, then continue.
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
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.