geethareddy commited on
Commit
8490c51
·
verified ·
1 Parent(s): 0534999

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -169,14 +169,14 @@ def process_command(command):
169
  all_items = {item.lower(): (category, price) for category, items in MENU.items() for item, price in items.items()}
170
  categories = {category.lower(): items for category, items in MENU.items()}
171
 
172
- if "menu" in command:
173
- menu = ", ".join([f"{category}: {', '.join(items.keys())}" for category, items in MENU.items()])
174
- return f"Here is our menu: {menu}."
175
- elif any(category in command for category in categories.keys()):
176
  category = next((cat for cat in categories.keys() if cat in command), None)
177
  if category:
178
  items = ", ".join(categories[category].keys())
179
  return f"{category.capitalize()} has {items}. What would you like to order?"
 
 
180
  elif any(item in command for item in all_items.keys()):
181
  item = next((item for item in all_items.keys() if item in command), None)
182
  if item:
@@ -185,6 +185,8 @@ def process_command(command):
185
  total = sum(item[1] for item in cart)
186
  cart_summary = ", ".join([f"{i[0]} (₹{i[1]})" for i in cart])
187
  return f"{item.title()} added to your cart for ₹{price}. Your cart: {cart_summary}. Total: ₹{total}. Do you want to order anything else?"
 
 
188
  elif "final order" in command or "submit" in command:
189
  if cart:
190
  items = ", ".join([f"{item[0]} (₹{item[1]})" for item in cart])
@@ -193,10 +195,13 @@ def process_command(command):
193
  return f"Your final order is: {items}. Total price: ₹{total}. Thank you for ordering!"
194
  else:
195
  return "Your cart is empty. Please add items first."
 
 
196
  elif "no" in command or "nothing" in command or "goodbye" in command:
197
  cart.clear()
198
  return "Goodbye! Thank you for using AI Dining Assistant."
 
199
  return "Sorry, I didn't understand that. Please try again."
200
 
201
  if __name__ == "__main__":
202
- app.run(host="0.0.0.0", port=7860)
 
169
  all_items = {item.lower(): (category, price) for category, items in MENU.items() for item, price in items.items()}
170
  categories = {category.lower(): items for category, items in MENU.items()}
171
 
172
+ # Handle category-specific queries
173
+ if any(category in command for category in categories.keys()):
 
 
174
  category = next((cat for cat in categories.keys() if cat in command), None)
175
  if category:
176
  items = ", ".join(categories[category].keys())
177
  return f"{category.capitalize()} has {items}. What would you like to order?"
178
+
179
+ # Handle specific item addition
180
  elif any(item in command for item in all_items.keys()):
181
  item = next((item for item in all_items.keys() if item in command), None)
182
  if item:
 
185
  total = sum(item[1] for item in cart)
186
  cart_summary = ", ".join([f"{i[0]} (₹{i[1]})" for i in cart])
187
  return f"{item.title()} added to your cart for ₹{price}. Your cart: {cart_summary}. Total: ₹{total}. Do you want to order anything else?"
188
+
189
+ # Handle final order
190
  elif "final order" in command or "submit" in command:
191
  if cart:
192
  items = ", ".join([f"{item[0]} (₹{item[1]})" for item in cart])
 
195
  return f"Your final order is: {items}. Total price: ₹{total}. Thank you for ordering!"
196
  else:
197
  return "Your cart is empty. Please add items first."
198
+
199
+ # Handle goodbye
200
  elif "no" in command or "nothing" in command or "goodbye" in command:
201
  cart.clear()
202
  return "Goodbye! Thank you for using AI Dining Assistant."
203
+
204
  return "Sorry, I didn't understand that. Please try again."
205
 
206
  if __name__ == "__main__":
207
+ app.run(host="0.0.0.0", port=7860)