hoangs commited on
Commit
6fa6e7f
·
verified ·
1 Parent(s): 29049bd

Upload model.py

Browse files
Files changed (1) hide show
  1. model.py +50 -0
model.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal, TypedDict
2
+
3
+ MaintTaskType = Literal["empty_bin", "clean_brush", "clean_filter", "firmware_update", "sensor_check"]
4
+
5
+ class MaintReminder(TypedDict):
6
+ should_remind: bool
7
+ urgency: Literal["low", "medium", "high"]
8
+ reason: str
9
+
10
+
11
+ def decide_maintenance_reminder(task_type: MaintTaskType, days_since_last: int) -> MaintReminder:
12
+ """Heuristic for when to remind about simple maintenance tasks."""
13
+ if task_type == "empty_bin":
14
+ if days_since_last >= 1:
15
+ return {"should_remind": True, "urgency": "high", "reason": "Dust bin should be emptied daily."}
16
+ return {"should_remind": False, "urgency": "low", "reason": "Bin recently emptied."}
17
+
18
+ if task_type == "clean_brush":
19
+ if days_since_last >= 7:
20
+ return {"should_remind": True, "urgency": "medium", "reason": "Brush should be cleaned weekly."}
21
+ return {"should_remind": False, "urgency": "low", "reason": "Brush cleaning not yet due."}
22
+
23
+ if task_type == "clean_filter":
24
+ if days_since_last >= 14:
25
+ return {"should_remind": True, "urgency": "medium", "reason": "Filter cleaning recommended every 2 weeks."}
26
+ return {"should_remind": False, "urgency": "low", "reason": "Filter cleaning not yet due."}
27
+
28
+ if task_type == "sensor_check":
29
+ if days_since_last >= 30:
30
+ return {"should_remind": True, "urgency": "low", "reason": "Monthly sensor self-check is due."}
31
+ return {"should_remind": False, "urgency": "low", "reason": "Sensor check recently performed."}
32
+
33
+ if task_type == "firmware_update":
34
+ if days_since_last >= 60:
35
+ return {"should_remind": True, "urgency": "low", "reason": "Check for firmware updates every few months."}
36
+ return {"should_remind": False, "urgency": "low", "reason": "Firmware update not yet necessary."}
37
+
38
+ return {"should_remind": False, "urgency": "low", "reason": "Unknown task type."}
39
+
40
+
41
+ if __name__ == "__main__":
42
+ tests = [
43
+ ("empty_bin", 2),
44
+ ("clean_brush", 8),
45
+ ("clean_filter", 10),
46
+ ("sensor_check", 31),
47
+ ("firmware_update", 90),
48
+ ]
49
+ for t, d in tests:
50
+ print(t, d, "->", decide_maintenance_reminder(t, d))