Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,8 @@ menu = {
|
|
| 8 |
"Starters": ["Soup", "Spring Rolls"],
|
| 9 |
"Main Course": ["Paneer Butter Masala", "Chicken Curry", "Veg Biryani"],
|
| 10 |
"Breads": ["Roti", "Naan", "Paratha"],
|
| 11 |
-
"Desserts": ["Gulab Jamun", "Ice Cream"]
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
# Context to track ongoing conversation
|
|
@@ -55,7 +56,7 @@ def process_order(audio_file_path):
|
|
| 55 |
if context["last_action"] == "show_menu":
|
| 56 |
response += "What would you like to order?"
|
| 57 |
else:
|
| 58 |
-
response += "Please let me know what you'd like to order. We have starters, main course, breads, and
|
| 59 |
context["last_action"] = "place_order"
|
| 60 |
|
| 61 |
elif any(item.lower() in user_input.lower() for item in sum(menu.values(), [])):
|
|
@@ -69,11 +70,25 @@ def process_order(audio_file_path):
|
|
| 69 |
|
| 70 |
elif "no" in user_input.lower() or "done" in user_input.lower():
|
| 71 |
if context["order"]:
|
| 72 |
-
response += f"Your final order is: {', '.join(context['order'])}.
|
| 73 |
-
context["
|
| 74 |
else:
|
| 75 |
response += "It seems you haven't ordered anything yet."
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
else:
|
| 78 |
response += "I'm not sure what you meant. Could you clarify?"
|
| 79 |
|
|
|
|
| 8 |
"Starters": ["Soup", "Spring Rolls"],
|
| 9 |
"Main Course": ["Paneer Butter Masala", "Chicken Curry", "Veg Biryani"],
|
| 10 |
"Breads": ["Roti", "Naan", "Paratha"],
|
| 11 |
+
"Desserts": ["Gulab Jamun", "Ice Cream"],
|
| 12 |
+
"Drinks": ["Mango Lassi", "Soda", "Water"]
|
| 13 |
}
|
| 14 |
|
| 15 |
# Context to track ongoing conversation
|
|
|
|
| 56 |
if context["last_action"] == "show_menu":
|
| 57 |
response += "What would you like to order?"
|
| 58 |
else:
|
| 59 |
+
response += "Please let me know what you'd like to order. We have starters, main course, breads, desserts, and drinks."
|
| 60 |
context["last_action"] = "place_order"
|
| 61 |
|
| 62 |
elif any(item.lower() in user_input.lower() for item in sum(menu.values(), [])):
|
|
|
|
| 70 |
|
| 71 |
elif "no" in user_input.lower() or "done" in user_input.lower():
|
| 72 |
if context["order"]:
|
| 73 |
+
response += f"Your final order is: {', '.join(context['order'])}. Shall I place this order for you?"
|
| 74 |
+
context["last_action"] = "confirm_order"
|
| 75 |
else:
|
| 76 |
response += "It seems you haven't ordered anything yet."
|
| 77 |
|
| 78 |
+
elif "yes" in user_input.lower() and context["last_action"] == "confirm_order":
|
| 79 |
+
response += f"Thank you! Your order for {', '.join(context['order'])} has been placed. Would you like to add a dessert or drink?"
|
| 80 |
+
context["last_action"] = "offer_suggestions"
|
| 81 |
+
|
| 82 |
+
elif any(item.lower() in user_input.lower() for item in menu["Desserts"] + menu["Drinks"]):
|
| 83 |
+
# Add desserts or drinks to the order
|
| 84 |
+
for item in menu["Desserts"] + menu["Drinks"]:
|
| 85 |
+
if item.lower() in user_input.lower():
|
| 86 |
+
context["order"].append(item)
|
| 87 |
+
response += f"I've added {item} to your order. Your updated order is: {', '.join(context['order'])}. Thank you for ordering with us!"
|
| 88 |
+
context["order"] = [] # Reset the order
|
| 89 |
+
context["last_action"] = None
|
| 90 |
+
break
|
| 91 |
+
|
| 92 |
else:
|
| 93 |
response += "I'm not sure what you meant. Could you clarify?"
|
| 94 |
|