Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 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 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 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()
|
|
|
|
| 1 |
+
menu = {
|
| 2 |
+
"breads": ["Roti", "Butter Naan", "Plain Naan", "Garlic Naan", "Chilly Naan"],
|
| 3 |
+
"veg_curries": ["Paneer Butter Masala", "Kadai Paneer", "Dum Ka Paneer", "Mixed Veg Curry", "Dal Makhani"],
|
| 4 |
+
"non_veg_curries": ["Chicken Curry", "Mutton Curry", "Fish Curry", "Prawns Curry"],
|
| 5 |
+
"biryani": ["Veg Biryani", "Paneer Biryani", "Chicken Biryani", "Mutton Biryani", "Fish Biryani", "Prawns Biryani"]
|
| 6 |
+
}
|
| 7 |
+
def suggest_pairings(selected_dishes):
|
| 8 |
+
# Default suggestions
|
| 9 |
+
suggested_pairings = {
|
| 10 |
+
"veg_curries": [],
|
| 11 |
+
"non_veg_curries": [],
|
| 12 |
+
"biryani": [],
|
| 13 |
+
"breads": [],
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
# If bread is selected
|
| 17 |
+
if any(bread in selected_dishes for bread in menu['breads']):
|
| 18 |
+
suggested_pairings["veg_curries"].extend(menu["veg_curries"])
|
| 19 |
+
suggested_pairings["non_veg_curries"].extend(menu["non_veg_curries"])
|
| 20 |
+
|
| 21 |
+
# If biryani is selected
|
| 22 |
+
if any(biryani in selected_dishes for biryani in menu["biryani"]):
|
| 23 |
+
suggested_pairings["veg_curries"].extend(menu["veg_curries"])
|
| 24 |
+
suggested_pairings["non_veg_curries"].extend(menu["non_veg_curries"])
|
| 25 |
+
|
| 26 |
+
# If only curries (veg or non-veg) are selected, suggest breads and biryanis
|
| 27 |
+
if any(curry in selected_dishes for curry in menu["veg_curries"] + menu["non_veg_curries"]):
|
| 28 |
+
suggested_pairings["breads"].extend(menu["breads"])
|
| 29 |
+
suggested_pairings["biryani"].extend(menu["biryani"])
|
| 30 |
+
|
| 31 |
+
return suggested_pairings
|
| 32 |
import gradio as gr
|
| 33 |
|
| 34 |
+
# Function to handle dish selection and show pairings
|
| 35 |
+
def dish_pairing(selected_bread, selected_curry, selected_biryani):
|
| 36 |
+
selected_dishes = [selected_bread, selected_curry, selected_biryani]
|
| 37 |
+
|
| 38 |
+
# Get the pairings based on selected dishes
|
| 39 |
+
pairings = suggest_pairings(selected_dishes)
|
| 40 |
+
|
| 41 |
+
# Create a response with the pairings
|
| 42 |
+
pairing_output = f"Suggested Pairings:\n\n"
|
| 43 |
+
|
| 44 |
+
if pairings["veg_curries"]:
|
| 45 |
+
pairing_output += f"Veg Curries: {', '.join(pairings['veg_curries'])}\n"
|
| 46 |
+
if pairings["non_veg_curries"]:
|
| 47 |
+
pairing_output += f"Non-Veg Curries: {', '.join(pairings['non_veg_curries'])}\n"
|
| 48 |
+
if pairings["biryani"]:
|
| 49 |
+
pairing_output += f"Biryani: {', '.join(pairings['biryani'])}\n"
|
| 50 |
+
if pairings["breads"]:
|
| 51 |
+
pairing_output += f"Breads: {', '.join(pairings['breads'])}\n"
|
| 52 |
+
|
| 53 |
+
return pairing_output
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# Create Gradio Interface
|
| 57 |
+
with gr.Blocks() as demo:
|
| 58 |
+
gr.Markdown("# Dish Pairing App")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
with gr.Row():
|
| 61 |
+
bread_input = gr.Radio(menu["breads"], label="Select a Bread", type="value")
|
| 62 |
+
curry_input = gr.Radio(menu["veg_curries"] + menu["non_veg_curries"], label="Select a Curry", type="value")
|
| 63 |
+
biryani_input = gr.Radio(menu["biryani"], label="Select a Biryani", type="value")
|
| 64 |
+
|
| 65 |
+
output = gr.Textbox(label="Suggested Pairings")
|
| 66 |
+
|
| 67 |
+
# Button to trigger pairing suggestions
|
| 68 |
+
submit_btn = gr.Button("Show Pairings")
|
| 69 |
+
|
| 70 |
+
submit_btn.click(dish_pairing, inputs=[bread_input, curry_input, biryani_input], outputs=output)
|
| 71 |
+
|
| 72 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|