Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,13 @@ logging.basicConfig(level=logging.INFO)
|
|
15 |
# Initialize conversation state
|
16 |
user_order = [] # Stores the current order
|
17 |
|
18 |
-
# Define food items (menu)
|
19 |
menu_items = {
|
20 |
-
'Veg': ["Vegetable Biryani",
|
21 |
-
'Non-Veg': ["Butter Chicken",
|
22 |
-
'Both': ["
|
23 |
-
'Drinks': ["Lassi", "
|
24 |
-
'Desserts': ["Gulab Jamun", "
|
25 |
}
|
26 |
|
27 |
# HTML Template for Frontend
|
@@ -246,14 +246,15 @@ def process_command(command):
|
|
246 |
|
247 |
command = command.lower()
|
248 |
|
249 |
-
# Show menu
|
250 |
if "show me the menu" in command or "what’s the menu" in command:
|
251 |
return (
|
252 |
"Here are the options: \n"
|
253 |
-
"Vegetarian: Vegetable Biryani
|
254 |
-
"Non-Veg: Butter Chicken
|
255 |
-
"
|
256 |
-
"
|
|
|
257 |
"Please let me know what you'd like to add to your order."
|
258 |
)
|
259 |
|
@@ -270,6 +271,8 @@ def process_command(command):
|
|
270 |
if item_to_remove in user_order:
|
271 |
user_order.remove(item_to_remove)
|
272 |
return f"{item_to_remove} has been removed from your order. Would you like to add or remove anything else?"
|
|
|
|
|
273 |
|
274 |
# Show current order
|
275 |
elif "show my order" in command or "what's my order" in command:
|
@@ -284,12 +287,15 @@ def process_command(command):
|
|
284 |
return f"You have the following items in your order: {', '.join(user_order)}. Would you like to confirm?"
|
285 |
else:
|
286 |
return "You haven't added anything to your order yet. Please add some items first."
|
287 |
-
|
288 |
-
# Final confirmation
|
289 |
elif "yes" in command or "place order" in command:
|
290 |
-
|
|
|
|
|
|
|
291 |
|
292 |
-
#
|
293 |
return (
|
294 |
"Sorry, I didn’t understand your request. You can say things like:\n"
|
295 |
"- Show me the menu\n"
|
@@ -299,5 +305,6 @@ def process_command(command):
|
|
299 |
"- Place the order"
|
300 |
)
|
301 |
|
|
|
302 |
if __name__ == "__main__":
|
303 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
15 |
# Initialize conversation state
|
16 |
user_order = [] # Stores the current order
|
17 |
|
18 |
+
# Define food items (menu) with only 10 items
|
19 |
menu_items = {
|
20 |
+
'Veg': ["Vegetable Biryani"], # 1 Veg item
|
21 |
+
'Non-Veg': ["Butter Chicken"], # 1 Non-Veg item
|
22 |
+
'Both': ["Paneer Butter Masala", "Chicken Biryani"], # 1 Veg + 1 Non-Veg item
|
23 |
+
'Drinks': ["Lassi", "Milkshake"], # 2 Drinks
|
24 |
+
'Desserts': ["Gulab Jamun", "Ice Cream"] # 2 Desserts
|
25 |
}
|
26 |
|
27 |
# HTML Template for Frontend
|
|
|
246 |
|
247 |
command = command.lower()
|
248 |
|
249 |
+
# Show the menu
|
250 |
if "show me the menu" in command or "what’s the menu" in command:
|
251 |
return (
|
252 |
"Here are the options: \n"
|
253 |
+
"Vegetarian: Vegetable Biryani\n"
|
254 |
+
"Non-Veg: Butter Chicken\n"
|
255 |
+
"Veg + Non-Veg: Paneer Butter Masala, Chicken Biryani\n"
|
256 |
+
"Drinks: Lassi, Milkshake\n"
|
257 |
+
"Desserts: Gulab Jamun, Ice Cream\n"
|
258 |
"Please let me know what you'd like to add to your order."
|
259 |
)
|
260 |
|
|
|
271 |
if item_to_remove in user_order:
|
272 |
user_order.remove(item_to_remove)
|
273 |
return f"{item_to_remove} has been removed from your order. Would you like to add or remove anything else?"
|
274 |
+
else:
|
275 |
+
return f"{item_to_remove} is not in your order. Please specify an item that is already in your order."
|
276 |
|
277 |
# Show current order
|
278 |
elif "show my order" in command or "what's my order" in command:
|
|
|
287 |
return f"You have the following items in your order: {', '.join(user_order)}. Would you like to confirm?"
|
288 |
else:
|
289 |
return "You haven't added anything to your order yet. Please add some items first."
|
290 |
+
|
291 |
+
# Final confirmation (user says yes to confirm the order)
|
292 |
elif "yes" in command or "place order" in command:
|
293 |
+
if user_order:
|
294 |
+
return "Your order has been confirmed and sent to the kitchen. Thank you for ordering!"
|
295 |
+
else:
|
296 |
+
return "Please add some items to your order before confirming."
|
297 |
|
298 |
+
# Handle unrecognized commands
|
299 |
return (
|
300 |
"Sorry, I didn’t understand your request. You can say things like:\n"
|
301 |
"- Show me the menu\n"
|
|
|
305 |
"- Place the order"
|
306 |
)
|
307 |
|
308 |
+
|
309 |
if __name__ == "__main__":
|
310 |
+
app.run(host="0.0.0.0", port=7860)
|