Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,67 +1,59 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Define menu
|
| 4 |
breads = ['Roti', 'Butter Naan', 'Plain Naan', 'Garlic Naan', 'Chilly Naan']
|
| 5 |
veg_curries = ['Paneer Butter Masala', 'Kadai Paneer', 'Dum Ka Paneer', 'Mixed Veg Curry', 'Dal Makhani']
|
| 6 |
non_veg_curries = ['Chicken Curry', 'Mutton Curry', 'Fish Curry', 'Prawns Curry']
|
| 7 |
biryani = ['Veg Biryani', 'Paneer Biryani', 'Chicken Biryani', 'Mutton Biryani', 'Fish Biryani', 'Prawns Biryani']
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
output_box.update(value=final_selection)
|
| 55 |
-
return suggestions, final_selection
|
| 56 |
-
|
| 57 |
-
# Set up the interaction logic
|
| 58 |
-
menu.change(fn=handle_selection, inputs=[menu, custom_box], outputs=[suggestion_box, output_box])
|
| 59 |
-
next_button.click(fn=handle_selection, inputs=[menu, custom_box], outputs=output_box)
|
| 60 |
-
|
| 61 |
-
return demo
|
| 62 |
-
|
| 63 |
-
# Create the interface
|
| 64 |
-
demo = create_interface()
|
| 65 |
-
|
| 66 |
-
# Launch the Gradio app
|
| 67 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Define menu categories
|
| 4 |
breads = ['Roti', 'Butter Naan', 'Plain Naan', 'Garlic Naan', 'Chilly Naan']
|
| 5 |
veg_curries = ['Paneer Butter Masala', 'Kadai Paneer', 'Dum Ka Paneer', 'Mixed Veg Curry', 'Dal Makhani']
|
| 6 |
non_veg_curries = ['Chicken Curry', 'Mutton Curry', 'Fish Curry', 'Prawns Curry']
|
| 7 |
biryani = ['Veg Biryani', 'Paneer Biryani', 'Chicken Biryani', 'Mutton Biryani', 'Fish Biryani', 'Prawns Biryani']
|
| 8 |
|
| 9 |
+
# Define the logic for suggestions
|
| 10 |
+
def get_suggestions(selected_items):
|
| 11 |
+
# If bread is selected, suggest curries and biryanis
|
| 12 |
+
if any(bread in selected_items for bread in breads):
|
| 13 |
+
suggestions = veg_curries + non_veg_curries
|
| 14 |
+
remaining_category = biryani # suggest biryanis if bread is selected
|
| 15 |
+
# If curries are selected, suggest bread and biryanis
|
| 16 |
+
elif any(curry in selected_items for curry in veg_curries + non_veg_curries):
|
| 17 |
+
suggestions = breads # suggest breads if curries are selected
|
| 18 |
+
remaining_category = biryani # suggest biryanis if curries are selected
|
| 19 |
+
# If biryanis are selected, suggest breads and curries
|
| 20 |
+
elif any(bir in selected_items for bir in biryani):
|
| 21 |
+
suggestions = breads + veg_curries + non_veg_curries # suggest breads and curries if biryanis are selected
|
| 22 |
+
remaining_category = [] # no remaining category if biryanis are selected
|
| 23 |
+
else:
|
| 24 |
+
suggestions = []
|
| 25 |
+
remaining_category = []
|
| 26 |
+
|
| 27 |
+
return suggestions, remaining_category
|
| 28 |
+
|
| 29 |
+
# Define the customization options box
|
| 30 |
+
def customize_selections(selected_items, custom_ingredients):
|
| 31 |
+
return f"Selected Items: {', '.join(selected_items)}\nCustom Ingredients: {custom_ingredients}"
|
| 32 |
+
|
| 33 |
+
# Gradio interface
|
| 34 |
+
def select_menu_and_customize(menu_items, custom_ingredients):
|
| 35 |
+
suggestions, remaining_category = get_suggestions(menu_items)
|
| 36 |
|
| 37 |
+
# Return suggestions for the next selection step
|
| 38 |
+
return suggestions, remaining_category, customize_selections(menu_items, custom_ingredients)
|
| 39 |
+
|
| 40 |
+
# Create the Gradio interface
|
| 41 |
+
menu_options = breads + veg_curries + non_veg_curries + biryani
|
| 42 |
+
|
| 43 |
+
# Create the Gradio interface
|
| 44 |
+
interface = gr.Interface(
|
| 45 |
+
fn=select_menu_and_customize,
|
| 46 |
+
inputs=[
|
| 47 |
+
gr.CheckboxGroup(choices=menu_options, label="Select your menu items"),
|
| 48 |
+
gr.Textbox(placeholder="Add any custom ingredients here", label="Custom Ingredients")
|
| 49 |
+
],
|
| 50 |
+
outputs=[
|
| 51 |
+
gr.CheckboxGroup(label="Suggestions based on your selections"),
|
| 52 |
+
gr.Textbox(label="Remaining options"),
|
| 53 |
+
gr.Textbox(label="Final Order Summary")
|
| 54 |
+
],
|
| 55 |
+
live=True, # This ensures suggestions update as the user makes selections
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# Launch the app
|
| 59 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|