BMS Deployer commited on
Commit
ba447c4
·
1 Parent(s): 43cbbcd

Fix intent priority and regex

Browse files
Files changed (1) hide show
  1. app/intent_parser.py +12 -10
app/intent_parser.py CHANGED
@@ -23,22 +23,24 @@ class IntentParser:
23
  response["intent"] = "list_locations"
24
  elif any(x in text for x in ["forecast", "demand", "predict", "future", "sales"]):
25
  response["intent"] = "demand_forecast"
26
- elif any(x in text for x in ["details", "info", "about", "price", "description"]):
27
- response["intent"] = "item_details"
28
- elif any(x in text for x in ["inventory", "stock", "how many", "available", "on hand"]):
29
  response["intent"] = "check_inventory"
30
- elif any(x in text for x in ["supplier", "vendor", "who supplies", "lead time"]):
31
  response["intent"] = "supplier_info"
32
- elif any(x in text for x in ["buy", "order", "purchase", "requisition"]):
33
  response["intent"] = "create_requisition"
34
- elif any(x in text for x in ["status", "alerts", "dashboard", "overview"]):
35
- response["intent"] = "system_status"
36
- elif any(x in text for x in ["pdf", "download", "report", "file"]):
37
  response["intent"] = "generate_report"
 
 
 
 
 
38
 
39
  # 2. Extract Item Code
40
- # Look for patterns like FS1234, BMS0001, etc. (2-3 letters + 4 digits)
41
- item_match = re.search(r'\b([a-z]{2,3}\d{4})\b', text)
42
  if item_match:
43
  response["item_code"] = item_match.group(1).upper()
44
  else:
 
23
  response["intent"] = "list_locations"
24
  elif any(x in text for x in ["forecast", "demand", "predict", "future", "sales"]):
25
  response["intent"] = "demand_forecast"
26
+ # Specific intents BEFORE generic "details/info"
27
+ elif any(x in text for x in ["inventory", "stock", "how many", "available", "on hand", "count", "quantity of"]):
 
28
  response["intent"] = "check_inventory"
29
+ elif any(x in text for x in ["supplier", "vendor", "who supplies", "lead time", "source"]):
30
  response["intent"] = "supplier_info"
31
+ elif any(x in text for x in ["buy", "order", "purchase", "requisition", "procure"]):
32
  response["intent"] = "create_requisition"
33
+ elif any(x in text for x in ["pdf", "download", "report", "file", "document"]):
 
 
34
  response["intent"] = "generate_report"
35
+ elif any(x in text for x in ["status", "alerts", "dashboard", "overview", "health"]):
36
+ response["intent"] = "system_status"
37
+ # Generic fallback
38
+ elif any(x in text for x in ["details", "info", "about", "price", "description"]):
39
+ response["intent"] = "item_details"
40
 
41
  # 2. Extract Item Code
42
+ # Look for patterns like FS123, BMS0001, etc. (2-3 letters + 3-5 digits)
43
+ item_match = re.search(r'\b([a-z]{2,3}\d{3,5})\b', text)
44
  if item_match:
45
  response["item_code"] = item_match.group(1).upper()
46
  else: