Update app.py
Browse files
app.py
CHANGED
@@ -241,12 +241,13 @@ def process_audio():
|
|
241 |
def process_command(command):
|
242 |
global user_order
|
243 |
|
|
|
244 |
command = command.lower()
|
245 |
|
246 |
# Show the menu without categorizing the items
|
247 |
if "menu" in command or "what’s the menu" in command or "Show me the menu" in command:
|
248 |
menu_response = (
|
249 |
-
"Here are the available
|
250 |
"Vegetable Biryani\n"
|
251 |
"Butter Chicken\n"
|
252 |
"Paneer Butter Masala\n"
|
@@ -262,18 +263,13 @@ def process_command(command):
|
|
262 |
# Add item to order
|
263 |
elif "add" in command:
|
264 |
item_to_add = command.split("add")[-1].strip()
|
265 |
-
|
|
|
|
|
266 |
user_order.append(item_to_add)
|
267 |
return f"{item_to_add} has been added to your order. Would you like to add more items?"
|
268 |
-
|
269 |
-
# Remove item from order
|
270 |
-
elif "remove" in command:
|
271 |
-
item_to_remove = command.split("remove")[-1].strip()
|
272 |
-
if item_to_remove in user_order:
|
273 |
-
user_order.remove(item_to_remove)
|
274 |
-
return f"{item_to_remove} has been removed from your order. Would you like to add or remove anything else?"
|
275 |
else:
|
276 |
-
return f"{
|
277 |
|
278 |
# Show current order
|
279 |
elif "show my order" in command or "what's my order" in command or "what's in my order" in command:
|
@@ -282,15 +278,15 @@ def process_command(command):
|
|
282 |
else:
|
283 |
return "You haven't added anything to your order yet."
|
284 |
|
285 |
-
# Place order
|
286 |
elif "place order" in command or "confirm order" in command:
|
287 |
if user_order:
|
288 |
-
return f"You have the following items in your order: {', '.join(user_order)}. Would you like to confirm?"
|
289 |
else:
|
290 |
return "You haven't added anything to your order yet. Please add some items first."
|
291 |
|
292 |
# Final confirmation (user says yes to confirm the order)
|
293 |
-
elif "yes" in command
|
294 |
if user_order:
|
295 |
return "Your order has been confirmed and sent to the kitchen. Thank you for ordering!"
|
296 |
else:
|
@@ -298,9 +294,14 @@ def process_command(command):
|
|
298 |
|
299 |
# Handle unrecognized commands
|
300 |
return (
|
301 |
-
"Sorry,
|
|
|
|
|
|
|
|
|
302 |
)
|
303 |
|
304 |
|
|
|
305 |
if __name__ == "__main__":
|
306 |
app.run(host="0.0.0.0", port=7860)
|
|
|
241 |
def process_command(command):
|
242 |
global user_order
|
243 |
|
244 |
+
# Normalize the command to lowercase
|
245 |
command = command.lower()
|
246 |
|
247 |
# Show the menu without categorizing the items
|
248 |
if "menu" in command or "what’s the menu" in command or "Show me the menu" in command:
|
249 |
menu_response = (
|
250 |
+
"Here are the available food items: \n"
|
251 |
"Vegetable Biryani\n"
|
252 |
"Butter Chicken\n"
|
253 |
"Paneer Butter Masala\n"
|
|
|
263 |
# Add item to order
|
264 |
elif "add" in command:
|
265 |
item_to_add = command.split("add")[-1].strip()
|
266 |
+
|
267 |
+
# Check if the item is in the menu
|
268 |
+
if item_to_add in menu_items["Veg"] or item_to_add in menu_items["Non-Veg"] or item_to_add in menu_items["Both"] or item_to_add in menu_items["Drinks"] or item_to_add in menu_items["Desserts"]:
|
269 |
user_order.append(item_to_add)
|
270 |
return f"{item_to_add} has been added to your order. Would you like to add more items?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
else:
|
272 |
+
return f"Sorry, {item_to_add} is not available in the menu. Please choose from the available items."
|
273 |
|
274 |
# Show current order
|
275 |
elif "show my order" in command or "what's my order" in command or "what's in my order" in command:
|
|
|
278 |
else:
|
279 |
return "You haven't added anything to your order yet."
|
280 |
|
281 |
+
# Place order (Ask for confirmation)
|
282 |
elif "place order" in command or "confirm order" in command:
|
283 |
if user_order:
|
284 |
+
return f"You have the following items in your order: {', '.join(user_order)}. Would you like to confirm? (Say 'yes' to confirm, 'no' to cancel)"
|
285 |
else:
|
286 |
return "You haven't added anything to your order yet. Please add some items first."
|
287 |
|
288 |
# Final confirmation (user says yes to confirm the order)
|
289 |
+
elif "yes" in command:
|
290 |
if user_order:
|
291 |
return "Your order has been confirmed and sent to the kitchen. Thank you for ordering!"
|
292 |
else:
|
|
|
294 |
|
295 |
# Handle unrecognized commands
|
296 |
return (
|
297 |
+
"Sorry, I didn’t understand your request. You can say things like:\n"
|
298 |
+
"- Show me the menu\n"
|
299 |
+
"- Add [item] to my order\n"
|
300 |
+
"- Show my order\n"
|
301 |
+
"- Place the order"
|
302 |
)
|
303 |
|
304 |
|
305 |
+
|
306 |
if __name__ == "__main__":
|
307 |
app.run(host="0.0.0.0", port=7860)
|