Upload model.py
Browse files
model.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TypedDict
|
| 2 |
+
|
| 3 |
+
class LaundryAdvice(TypedDict):
|
| 4 |
+
should_remind: bool
|
| 5 |
+
urgency: str
|
| 6 |
+
reason: str
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def advise_laundry(fill_level_pct: float, days_since_last_wash: int, rain_forecast_tomorrow: bool) -> LaundryAdvice:
|
| 10 |
+
"""Give a simple reminder recommendation for laundry."""
|
| 11 |
+
urgent = False
|
| 12 |
+
should = False
|
| 13 |
+
reasons = []
|
| 14 |
+
|
| 15 |
+
if fill_level_pct >= 90 or days_since_last_wash >= 7:
|
| 16 |
+
should = True
|
| 17 |
+
urgent = True
|
| 18 |
+
reasons.append("Basket is very full or it has been a week since last wash.")
|
| 19 |
+
elif fill_level_pct >= 70 or days_since_last_wash >= 4:
|
| 20 |
+
should = True
|
| 21 |
+
reasons.append("Laundry basket is getting full or it has been several days.")
|
| 22 |
+
else:
|
| 23 |
+
reasons.append("Laundry level is moderate; no urgent need.")
|
| 24 |
+
|
| 25 |
+
if rain_forecast_tomorrow and should:
|
| 26 |
+
urgent = True
|
| 27 |
+
reasons.append("Rain is forecast tomorrow; better wash and dry today.")
|
| 28 |
+
|
| 29 |
+
urgency = "high" if urgent else ("medium" if should else "low")
|
| 30 |
+
return {
|
| 31 |
+
"should_remind": should,
|
| 32 |
+
"urgency": urgency,
|
| 33 |
+
"reason": " ".join(reasons),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
tests = [
|
| 39 |
+
(95, 8, False),
|
| 40 |
+
(80, 3, True),
|
| 41 |
+
(60, 2, False),
|
| 42 |
+
(40, 1, False),
|
| 43 |
+
]
|
| 44 |
+
for f, d, r in tests:
|
| 45 |
+
print(f, d, r, "->", advise_laundry(f, d, r))
|