hoangs commited on
Commit
f8742bd
·
verified ·
1 Parent(s): cf12816

Upload model.py

Browse files
Files changed (1) hide show
  1. model.py +30 -0
model.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ def _time_period(hour: int) -> str:
4
+ if 5 <= hour < 11:
5
+ return "buổi sáng"
6
+ if 11 <= hour < 13:
7
+ return "buổi trưa"
8
+ if 13 <= hour < 18:
9
+ return "buổi chiều"
10
+ if 18 <= hour < 23:
11
+ return "buổi tối"
12
+ return "khuya"
13
+
14
+ def make_greeting(user_name: str | None = None, now: datetime | None = None) -> str:
15
+ """Generate a simple Vietnamese greeting for a user.
16
+
17
+ - user_name: optional short id or display name (not real name)
18
+ - now: optional datetime, defaults to current time
19
+ """
20
+ if now is None:
21
+ now = datetime.now()
22
+
23
+ period = _time_period(now.hour)
24
+
25
+ if user_name:
26
+ return f"Chào {period}, {user_name}! Tôi có thể giúp gì cho bạn hôm nay?"
27
+ return f"Chào {period}! Tôi có thể giúp gì cho bạn hôm nay?"
28
+
29
+ if __name__ == "__main__":
30
+ print(make_greeting("user_a"))