Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,6 @@ logging.basicConfig(level=logging.INFO)
|
|
| 14 |
|
| 15 |
# Initialize conversation state
|
| 16 |
user_order = [] # Stores the current order
|
| 17 |
-
user_preferences = None # Stores the customer's preferences (Veg, Non-Veg/Halal, or Both)
|
| 18 |
|
| 19 |
# Define food items
|
| 20 |
menu_items = {
|
|
@@ -177,7 +176,7 @@ def index():
|
|
| 177 |
|
| 178 |
@app.route('/process-audio', methods=['POST'])
|
| 179 |
def process_audio():
|
| 180 |
-
global user_order
|
| 181 |
try:
|
| 182 |
# Validate audio file
|
| 183 |
audio_file = request.files.get('audio')
|
|
@@ -239,27 +238,32 @@ def process_audio():
|
|
| 239 |
logging.error(f"Error cleaning up files: {cleanup_error}")
|
| 240 |
|
| 241 |
def process_command(command):
|
| 242 |
-
global user_order
|
| 243 |
|
| 244 |
command = command.lower()
|
| 245 |
if "hello" in command or "hi" in command or "hey" in command:
|
| 246 |
return (
|
| 247 |
-
"Welcome! How can I assist you with your meal today? "
|
| 248 |
-
"Please let me know your preferences (Veg, Non-Veg/Halal, or Both)."
|
| 249 |
)
|
| 250 |
-
elif "
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
elif "
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
elif "show my order" in command or "what's my order" in command:
|
| 264 |
if user_order:
|
| 265 |
return "Your current order includes: " + ", ".join(user_order)
|
|
|
|
| 14 |
|
| 15 |
# Initialize conversation state
|
| 16 |
user_order = [] # Stores the current order
|
|
|
|
| 17 |
|
| 18 |
# Define food items
|
| 19 |
menu_items = {
|
|
|
|
| 176 |
|
| 177 |
@app.route('/process-audio', methods=['POST'])
|
| 178 |
def process_audio():
|
| 179 |
+
global user_order
|
| 180 |
try:
|
| 181 |
# Validate audio file
|
| 182 |
audio_file = request.files.get('audio')
|
|
|
|
| 238 |
logging.error(f"Error cleaning up files: {cleanup_error}")
|
| 239 |
|
| 240 |
def process_command(command):
|
| 241 |
+
global user_order
|
| 242 |
|
| 243 |
command = command.lower()
|
| 244 |
if "hello" in command or "hi" in command or "hey" in command:
|
| 245 |
return (
|
| 246 |
+
"Welcome! How can I assist you with your meal today? You can ask to see the menu or place an order."
|
|
|
|
| 247 |
)
|
| 248 |
+
elif "show me the menu" in command or "what's the menu" in command:
|
| 249 |
+
return (
|
| 250 |
+
"Here are the options: \n"
|
| 251 |
+
"Vegetarian: Vegetable Biryani, Paneer Butter Masala, Aloo Gobi, Veg Sambar, Veg Korma\n"
|
| 252 |
+
"Non-Veg: Butter Chicken, Chicken Biryani, Tandoori Chicken, Mutton Rogan Josh, Chicken Korma\n"
|
| 253 |
+
"Drinks: Lassi, Soft Drink, Lemon Juice, Iced Tea, Milkshake\n"
|
| 254 |
+
"Desserts: Gulab Jamun, Kheer, Ice Cream, Ras Malai\n"
|
| 255 |
+
"Please let me know what you'd like to add to your order."
|
| 256 |
+
)
|
| 257 |
+
elif "add" in command:
|
| 258 |
+
item_to_add = command.split("add")[-1].strip() # Get the item after "add"
|
| 259 |
+
if item_to_add:
|
| 260 |
+
user_order.append(item_to_add)
|
| 261 |
+
return f"{item_to_add} has been added to your order. Would you like to add more items?"
|
| 262 |
+
elif "remove" in command:
|
| 263 |
+
item_to_remove = command.split("remove")[-1].strip() # Get the item after "remove"
|
| 264 |
+
if item_to_remove in user_order:
|
| 265 |
+
user_order.remove(item_to_remove)
|
| 266 |
+
return f"{item_to_remove} has been removed from your order. Would you like to add or remove anything else?"
|
| 267 |
elif "show my order" in command or "what's my order" in command:
|
| 268 |
if user_order:
|
| 269 |
return "Your current order includes: " + ", ".join(user_order)
|