Fred808 commited on
Commit
e922b06
·
verified ·
1 Parent(s): c04f4ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -120,6 +120,30 @@ user_state = {}
120
  conversation_context = {}
121
  proactive_timer = {}
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  # --- Updated Menu for Creole Kings ---
124
  menu_items = [
125
  {"name": "Jambalaya", "description": "A classic Creole dish with rice, chicken, sausage, and shrimp", "price": 15, "nutrition": "Approximately 500 kcal"},
 
120
  conversation_context = {}
121
  proactive_timer = {}
122
 
123
+ from datetime import datetime, timedelta
124
+
125
+ SESSION_TIMEOUT = timedelta(minutes=5)
126
+
127
+ class ConversationState:
128
+ def __init__(self):
129
+ self.flow = None
130
+ self.step = 0
131
+ self.data = {}
132
+ self.last_active = datetime.utcnow()
133
+
134
+ def update_last_active(self):
135
+ self.last_active = datetime.utcnow()
136
+
137
+ def is_expired(self):
138
+ return datetime.utcnow() - self.last_active > SESSION_TIMEOUT
139
+
140
+ def reset(self):
141
+ self.flow = None
142
+ self.step = 0
143
+ self.data = {}
144
+ self.last_active = datetime.utcnow()
145
+
146
+
147
  # --- Updated Menu for Creole Kings ---
148
  menu_items = [
149
  {"name": "Jambalaya", "description": "A classic Creole dish with rice, chicken, sausage, and shrimp", "price": 15, "nutrition": "Approximately 500 kcal"},