Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -150,6 +150,11 @@ MENU_CONFIG = {
|
|
| 150 |
'valid_options': [], # Will be populated dynamically based on all products
|
| 151 |
'option_descriptions': {}
|
| 152 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
'product_inquiry': {
|
| 154 |
'name': 'Product Inquiry Menu',
|
| 155 |
'valid_options': ['1', '2', '3'],
|
|
@@ -189,6 +194,9 @@ def validate_menu_selection(selection: str, current_state: str, user_context: di
|
|
| 189 |
elif current_state == 'all_products_menu':
|
| 190 |
if products_df is not None and not products_df.empty:
|
| 191 |
valid_options = [str(i) for i in range(1, len(products_df) + 1)]
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
# Check if selection is valid
|
| 194 |
if selection in valid_options:
|
|
@@ -233,6 +241,13 @@ def get_menu_info(current_state: str, user_context: dict) -> dict:
|
|
| 233 |
str(i): product.get('Product Name', f'Product {i}')
|
| 234 |
for i, product in enumerate(all_products, 1)
|
| 235 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
return menu_config
|
| 238 |
|
|
|
|
| 150 |
'valid_options': [], # Will be populated dynamically based on all products
|
| 151 |
'option_descriptions': {}
|
| 152 |
},
|
| 153 |
+
'intelligent_products_menu': {
|
| 154 |
+
'name': 'Intelligent Products Menu',
|
| 155 |
+
'valid_options': [], # Will be populated dynamically based on available products
|
| 156 |
+
'option_descriptions': {}
|
| 157 |
+
},
|
| 158 |
'product_inquiry': {
|
| 159 |
'name': 'Product Inquiry Menu',
|
| 160 |
'valid_options': ['1', '2', '3'],
|
|
|
|
| 194 |
elif current_state == 'all_products_menu':
|
| 195 |
if products_df is not None and not products_df.empty:
|
| 196 |
valid_options = [str(i) for i in range(1, len(products_df) + 1)]
|
| 197 |
+
elif current_state == 'intelligent_products_menu':
|
| 198 |
+
available_products = user_context.get('available_products', [])
|
| 199 |
+
valid_options = [str(i) for i in range(1, len(available_products) + 1)]
|
| 200 |
|
| 201 |
# Check if selection is valid
|
| 202 |
if selection in valid_options:
|
|
|
|
| 241 |
str(i): product.get('Product Name', f'Product {i}')
|
| 242 |
for i, product in enumerate(all_products, 1)
|
| 243 |
}
|
| 244 |
+
elif current_state == 'intelligent_products_menu':
|
| 245 |
+
available_products = user_context.get('available_products', [])
|
| 246 |
+
menu_config['valid_options'] = [str(i) for i in range(1, len(available_products) + 1)]
|
| 247 |
+
menu_config['option_descriptions'] = {
|
| 248 |
+
str(i): product.get('Product Name', f'Product {i}')
|
| 249 |
+
for i, product in enumerate(available_products, 1)
|
| 250 |
+
}
|
| 251 |
|
| 252 |
return menu_config
|
| 253 |
|