Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,10 +18,10 @@ section_preferences = None # Tracks the current section preference
|
|
| 18 |
default_menu_preferences = "all" # To reset menu preferences
|
| 19 |
default_sections = {
|
| 20 |
"biryanis": ["veg biryani", "paneer biryani", "chicken biryani", "mutton biryani"],
|
| 21 |
-
"starters": ["samosa", "onion pakoda", "chilli gobi", "chicken manchurian", "veg manchurian"],
|
| 22 |
-
"curries": ["paneer butter", "chicken curry", "fish curry", "
|
| 23 |
"desserts": ["gulab jamun", "ice cream"],
|
| 24 |
-
"soft drinks": ["
|
| 25 |
}
|
| 26 |
prices = {
|
| 27 |
"samosa": 9,
|
|
@@ -40,12 +40,13 @@ prices = {
|
|
| 40 |
"gulab jamun": 8,
|
| 41 |
"ice cream": 6,
|
| 42 |
"cola": 5,
|
|
|
|
| 43 |
"lemon soda": 6
|
| 44 |
}
|
| 45 |
menus = {
|
| 46 |
"all": list(prices.keys()),
|
| 47 |
"vegetarian": [
|
| 48 |
-
"samosa", "onion pakoda", "chilli gobi", "veg biryani", "paneer butter", "veg manchurian", "paneer biryani", "gulab jamun", "ice cream", "cola", "lemon soda"
|
| 49 |
],
|
| 50 |
"non-vegetarian": [
|
| 51 |
"chicken biryani", "mutton biryani", "fish curry", "chicken manchurian", "chilli chicken", "chicken curry", "gulab jamun", "ice cream", "cola", "lemon soda"
|
|
@@ -219,7 +220,7 @@ def process_command(command):
|
|
| 219 |
|
| 220 |
# Fuzzy match: Try to find the closest match in the cart
|
| 221 |
closest_match = process.extractOne(command, [i[0] for i in cart], scorer=fuzz.partial_ratio)
|
| 222 |
-
if closest_match and closest_match[1] >
|
| 223 |
matched_item = closest_match[0]
|
| 224 |
cart = [item for item in cart if item[0] != matched_item]
|
| 225 |
cart_summary = ", ".join([f"{i[0]} x{i[2]} (${i[1] * i[2]})" for i in cart]) if cart else "Your cart is now empty."
|
|
@@ -236,7 +237,7 @@ def process_command(command):
|
|
| 236 |
cart.clear()
|
| 237 |
menu_preferences = None
|
| 238 |
section_preferences = None
|
| 239 |
-
return f"Your final order is: {order_summary}. Total bill: ${total}. Thank you for ordering!
|
| 240 |
|
| 241 |
return "Your cart is empty. Please add items to your cart first."
|
| 242 |
|
|
@@ -332,7 +333,7 @@ html_code = """
|
|
| 332 |
}
|
| 333 |
});
|
| 334 |
function startConversation() {
|
| 335 |
-
const utterance = new SpeechSynthesisUtterance('Please choose your preference: All, Vegetarian, or Non-Vegetarian.');
|
| 336 |
speechSynthesis.speak(utterance);
|
| 337 |
utterance.onend = () => {
|
| 338 |
status.textContent = 'Listening...';
|
|
|
|
| 18 |
default_menu_preferences = "all" # To reset menu preferences
|
| 19 |
default_sections = {
|
| 20 |
"biryanis": ["veg biryani", "paneer biryani", "chicken biryani", "mutton biryani"],
|
| 21 |
+
"starters": ["samosa", "onion pakoda", "chilli gobi", "chicken manchurian", "veg manchurian", "chilli chicken"],
|
| 22 |
+
"curries": ["paneer butter", "chicken curry", "fish curry", "mashroom curry"],
|
| 23 |
"desserts": ["gulab jamun", "ice cream"],
|
| 24 |
+
"soft drinks": ["Thums up", "lemon soda"]
|
| 25 |
}
|
| 26 |
prices = {
|
| 27 |
"samosa": 9,
|
|
|
|
| 40 |
"gulab jamun": 8,
|
| 41 |
"ice cream": 6,
|
| 42 |
"cola": 5,
|
| 43 |
+
"mashroom curry": 6,
|
| 44 |
"lemon soda": 6
|
| 45 |
}
|
| 46 |
menus = {
|
| 47 |
"all": list(prices.keys()),
|
| 48 |
"vegetarian": [
|
| 49 |
+
"samosa", "onion pakoda", "chilli gobi", "veg biryani", "paneer butter", "veg manchurian", "paneer biryani", "mashroom curry", "gulab jamun", "ice cream", "cola", "lemon soda"
|
| 50 |
],
|
| 51 |
"non-vegetarian": [
|
| 52 |
"chicken biryani", "mutton biryani", "fish curry", "chicken manchurian", "chilli chicken", "chicken curry", "gulab jamun", "ice cream", "cola", "lemon soda"
|
|
|
|
| 220 |
|
| 221 |
# Fuzzy match: Try to find the closest match in the cart
|
| 222 |
closest_match = process.extractOne(command, [i[0] for i in cart], scorer=fuzz.partial_ratio)
|
| 223 |
+
if closest_match and closest_match[1] > 65: # Stricter threshold
|
| 224 |
matched_item = closest_match[0]
|
| 225 |
cart = [item for item in cart if item[0] != matched_item]
|
| 226 |
cart_summary = ", ".join([f"{i[0]} x{i[2]} (${i[1] * i[2]})" for i in cart]) if cart else "Your cart is now empty."
|
|
|
|
| 237 |
cart.clear()
|
| 238 |
menu_preferences = None
|
| 239 |
section_preferences = None
|
| 240 |
+
return f"Your final order is: {order_summary}. Total bill: ${total}. Thank you for ordering! visit again."
|
| 241 |
|
| 242 |
return "Your cart is empty. Please add items to your cart first."
|
| 243 |
|
|
|
|
| 333 |
}
|
| 334 |
});
|
| 335 |
function startConversation() {
|
| 336 |
+
const utterance = new SpeechSynthesisUtterance(' Welcome to Biryani hub Please choose your preference: All, Vegetarian, or Non-Vegetarian.');
|
| 337 |
speechSynthesis.speak(utterance);
|
| 338 |
utterance.onend = () => {
|
| 339 |
status.textContent = 'Listening...';
|