dschandra commited on
Commit
466cb38
·
verified ·
1 Parent(s): 0af1f1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
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, user_preferences
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, user_preferences
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 "veg" in command:
251
- user_preferences = "Veg"
252
- return "You selected Veg. Here are the options: " + ", ".join(menu_items["Veg"]) + ". What would you like to add?"
253
- elif "non-veg" in command or "halal" in command:
254
- user_preferences = "Non-Veg"
255
- return "You selected Non-Veg/Halal. Here are the options: " + ", ".join(menu_items["Non-Veg"]) + ". What would you like to add?"
256
- elif "both" in command:
257
- user_preferences = "Both"
258
- return "You selected Both. Here are the options: " + ", ".join(menu_items["Both"]) + ". What would you like to add?"
259
- elif "reset preferences" in command:
260
- user_order = [] # Reset the order
261
- user_preferences = None # Reset preferences
262
- return "Your preferences have been reset. What would you like to order?"
 
 
 
 
 
 
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)