Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,65 +1,79 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Define
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
'Veg Biryani', 'Paneer Biryani', 'Chicken Biryani', 'Mutton Biryani', 'Fish Biryani', 'Prawns Biryani' # Biryani
|
| 9 |
-
]
|
| 10 |
|
| 11 |
-
#
|
| 12 |
def suggest_pairings(selected_items):
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
if any(curry in selected_items for curry in ['Paneer Butter Masala', 'Kadai Paneer', 'Dum Ka Paneer', 'Mixed Veg Curry', 'Dal Makhani']):
|
| 21 |
-
suggestions.append('Veg curries go well with rice-based dishes like Biryani')
|
| 22 |
-
|
| 23 |
-
if any(curry in selected_items for curry in ['Chicken Curry', 'Mutton Curry', 'Fish Curry', 'Prawns Curry']):
|
| 24 |
-
suggestions.append('Non-Veg curries pair excellently with Biryani and Bread')
|
| 25 |
-
|
| 26 |
-
# Suggestions based on Biryani selection
|
| 27 |
-
if any(biryani in selected_items for biryani in ['Veg Biryani', 'Paneer Biryani', 'Chicken Biryani', 'Mutton Biryani', 'Fish Biryani', 'Prawns Biryani']):
|
| 28 |
-
suggestions.append('Biryani pairs well with raita, naan, or a curry')
|
| 29 |
-
|
| 30 |
-
# Customize the suggestion list
|
| 31 |
-
if not suggestions:
|
| 32 |
-
suggestions.append('Select more dishes to get suggestions!')
|
| 33 |
-
|
| 34 |
-
return '\n'.join(suggestions)
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
pairing_output = gr.Textbox(label="Pairing Suggestions")
|
| 49 |
-
customization_output = gr.Textbox(label="Customization Box", interactive=True)
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
)
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
|
|
|
|
| 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 |
+
# Function to provide suggestions based on selection
|
| 10 |
def suggest_pairings(selected_items):
|
| 11 |
+
# Create a set for selected items for easier matching
|
| 12 |
+
selected_set = set(selected_items)
|
| 13 |
|
| 14 |
+
# Initial suggestions
|
| 15 |
+
breads_suggested = []
|
| 16 |
+
veg_curries_suggested = []
|
| 17 |
+
non_veg_curries_suggested = []
|
| 18 |
+
biryani_suggested = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# Suggest items based on selection logic
|
| 21 |
+
if 'Roti' in selected_set or 'Butter Naan' in selected_set or 'Plain Naan' in selected_set or 'Garlic Naan' in selected_set or 'Chilly Naan' in selected_set:
|
| 22 |
+
veg_curries_suggested = veg_curries
|
| 23 |
+
non_veg_curries_suggested = non_veg_curries
|
| 24 |
+
elif 'Paneer Butter Masala' in selected_set or 'Kadai Paneer' in selected_set or 'Dum Ka Paneer' in selected_set or 'Mixed Veg Curry' in selected_set or 'Dal Makhani' in selected_set:
|
| 25 |
+
breads_suggested = breads
|
| 26 |
+
biryani_suggested = biryani
|
| 27 |
+
elif 'Chicken Curry' in selected_set or 'Mutton Curry' in selected_set or 'Fish Curry' in selected_set or 'Prawns Curry' in selected_set:
|
| 28 |
+
breads_suggested = breads
|
| 29 |
+
biryani_suggested = biryani
|
| 30 |
+
elif 'Veg Biryani' in selected_set or 'Paneer Biryani' in selected_set or 'Chicken Biryani' in selected_set or 'Mutton Biryani' in selected_set or 'Fish Biryani' in selected_set or 'Prawns Biryani' in selected_set:
|
| 31 |
+
breads_suggested = breads
|
| 32 |
+
veg_curries_suggested = veg_curries
|
| 33 |
+
non_veg_curries_suggested = non_veg_curries
|
| 34 |
|
| 35 |
+
# If nothing selected, suggest everything
|
| 36 |
+
if not selected_items:
|
| 37 |
+
breads_suggested = breads
|
| 38 |
+
veg_curries_suggested = veg_curries
|
| 39 |
+
non_veg_curries_suggested = non_veg_curries
|
| 40 |
+
biryani_suggested = biryani
|
| 41 |
|
| 42 |
+
return breads_suggested, veg_curries_suggested, non_veg_curries_suggested, biryani_suggested
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# Function to handle user input and generate suggestions
|
| 45 |
+
def menu_selection(selected_items, custom_ingredient):
|
| 46 |
+
# Get suggestions based on selected items
|
| 47 |
+
breads_suggested, veg_curries_suggested, non_veg_curries_suggested, biryani_suggested = suggest_pairings(selected_items)
|
| 48 |
+
|
| 49 |
+
# Combine suggestions into one string for easy display
|
| 50 |
+
suggestions = f"Suggested Pairings:\n\nBreads: {', '.join(breads_suggested)}\nVeg Curries: {', '.join(veg_curries_suggested)}\nNon-Veg Curries: {', '.join(non_veg_curries_suggested)}\nBiryani: {', '.join(biryani_suggested)}"
|
| 51 |
+
|
| 52 |
+
return suggestions, f"Custom Ingredient: {custom_ingredient}"
|
| 53 |
|
| 54 |
+
# Gradio UI
|
| 55 |
+
def create_ui():
|
| 56 |
+
# Define the menu with all items for selection
|
| 57 |
+
menu_items = breads + veg_curries + non_veg_curries + biryani
|
| 58 |
+
|
| 59 |
+
# Gradio interface with the selection box and custom input box
|
| 60 |
+
with gr.Blocks() as demo:
|
| 61 |
+
with gr.Row():
|
| 62 |
+
menu_box = gr.CheckboxGroup(label="Select Menu Items", choices=menu_items, type="value")
|
| 63 |
+
custom_box = gr.Textbox(label="Customize Dish (Add Ingredients)", placeholder="e.g., Extra Cheese, Spicy", lines=2)
|
| 64 |
+
|
| 65 |
+
with gr.Row():
|
| 66 |
+
next_button = gr.Button("Next")
|
| 67 |
+
|
| 68 |
+
suggestions_output = gr.Textbox(label="Suggestions Based on Your Selection", interactive=False)
|
| 69 |
+
|
| 70 |
+
# Define the event when "Next" is clicked
|
| 71 |
+
next_button.click(fn=menu_selection, inputs=[menu_box, custom_box], outputs=[suggestions_output, custom_box])
|
| 72 |
+
|
| 73 |
+
return demo
|
| 74 |
|
| 75 |
+
# Run the app
|
| 76 |
+
demo = create_ui()
|
| 77 |
+
demo.launch()
|
| 78 |
|
| 79 |
|