def detect_intent(message: str): """ A robust, rule-based classifier for warehouse tasks. Returns one of: - "slotting" - "picking" - "report" """ msg = message.lower().strip() # ----------------------------- # SLOTING KEYWORDS # ----------------------------- slot_keywords = [ "slot", "slotting", "putaway", "storage location", "rearrange items", "reorganize racks", "optimize space", "velocity", "sku placement", "bin allocation" ] # ----------------------------- # PICKING KEYWORDS # ----------------------------- pick_keywords = [ "pick", "picking", "route", "path", "walk sequence", "shortest path", "aisle", "rack", "order fulfillment", "picklist" ] # ----------------------------- # FULL REPORT KEYWORDS # ----------------------------- report_keywords = [ "full report", "overall performance", "warehouse report", "summary", "end to end", "combined", "complete report", "all optimizations" ] # ----------------------------- # PRIORITY: Full Report → Slotting → Picking # (Prevents overlap confusion) # ----------------------------- if any(k in msg for k in report_keywords): return "report" if any(k in msg for k in slot_keywords): return "slotting" if any(k in msg for k in pick_keywords): return "picking" # ----------------------------- # UNKNOWN → DEFAULT TO REPORT # ----------------------------- return "report"