Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,12 +122,12 @@ def process_command(command):
|
|
| 122 |
|
| 123 |
# Handle menu preferences
|
| 124 |
if menu_preferences is None:
|
| 125 |
-
if "vegetarian" in command:
|
| 126 |
-
menu_preferences = "vegetarian"
|
| 127 |
-
return "You have chosen the Vegetarian menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
| 128 |
-
elif "non-vegetarian" in command:
|
| 129 |
menu_preferences = "non-vegetarian"
|
| 130 |
return "You have chosen the Non-Vegetarian menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
|
|
|
|
|
|
|
|
|
| 131 |
elif "all" in command:
|
| 132 |
menu_preferences = "all"
|
| 133 |
return "You have chosen the complete menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
|
@@ -179,7 +179,6 @@ def process_command(command):
|
|
| 179 |
return "Your cart is empty. Please add items to your cart first."
|
| 180 |
|
| 181 |
return "Sorry, I couldn't understand that. Please try again."
|
| 182 |
-
|
| 183 |
def extract_quantity(command):
|
| 184 |
"""
|
| 185 |
Extract quantity from the user command.
|
|
@@ -187,23 +186,22 @@ def extract_quantity(command):
|
|
| 187 |
# Map numeric words to digits
|
| 188 |
number_words = {
|
| 189 |
"one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
|
| 190 |
-
"six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10
|
|
|
|
| 191 |
}
|
| 192 |
|
| 193 |
-
#
|
| 194 |
-
|
| 195 |
-
if word.isdigit():
|
| 196 |
-
quantity = int(word)
|
| 197 |
-
if 1 <= quantity <= 10:
|
| 198 |
-
return quantity
|
| 199 |
|
| 200 |
-
# Check for numeric words
|
| 201 |
-
for word in
|
| 202 |
if word in number_words:
|
| 203 |
return number_words[word]
|
| 204 |
|
| 205 |
return None
|
| 206 |
|
|
|
|
|
|
|
| 207 |
html_code = """
|
| 208 |
<!DOCTYPE html>
|
| 209 |
<html lang="en">
|
|
|
|
| 122 |
|
| 123 |
# Handle menu preferences
|
| 124 |
if menu_preferences is None:
|
| 125 |
+
if "non-vegetarian" in command:
|
|
|
|
|
|
|
|
|
|
| 126 |
menu_preferences = "non-vegetarian"
|
| 127 |
return "You have chosen the Non-Vegetarian menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
| 128 |
+
elif "vegetarian" in command:
|
| 129 |
+
menu_preferences = "vegetarian"
|
| 130 |
+
return "You have chosen the Vegetarian menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
| 131 |
elif "all" in command:
|
| 132 |
menu_preferences = "all"
|
| 133 |
return "You have chosen the complete menu. Which section would you like? (biryani, starters, curries, desserts, soft drinks)"
|
|
|
|
| 179 |
return "Your cart is empty. Please add items to your cart first."
|
| 180 |
|
| 181 |
return "Sorry, I couldn't understand that. Please try again."
|
|
|
|
| 182 |
def extract_quantity(command):
|
| 183 |
"""
|
| 184 |
Extract quantity from the user command.
|
|
|
|
| 186 |
# Map numeric words to digits
|
| 187 |
number_words = {
|
| 188 |
"one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
|
| 189 |
+
"six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10,
|
| 190 |
+
"1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10
|
| 191 |
}
|
| 192 |
|
| 193 |
+
# Normalize command and split into words
|
| 194 |
+
command_words = command.split()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
+
# Check for numeric words or digits in the command
|
| 197 |
+
for word in command_words:
|
| 198 |
if word in number_words:
|
| 199 |
return number_words[word]
|
| 200 |
|
| 201 |
return None
|
| 202 |
|
| 203 |
+
|
| 204 |
+
|
| 205 |
html_code = """
|
| 206 |
<!DOCTYPE html>
|
| 207 |
<html lang="en">
|