Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,72 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 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 |
-
#
|
| 22 |
-
if
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
if
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
return
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 62 |
-
curry_input = gr.
|
| 63 |
-
biryani_input = gr.
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
# Button to trigger pairing suggestions
|
| 68 |
-
submit_btn = gr.Button("Show Pairings")
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Menu Data
|
| 4 |
menu = {
|
| 5 |
"breads": ["Roti", "Butter Naan", "Plain Naan", "Garlic Naan", "Chilly Naan"],
|
| 6 |
"veg_curries": ["Paneer Butter Masala", "Kadai Paneer", "Dum Ka Paneer", "Mixed Veg Curry", "Dal Makhani"],
|
| 7 |
"non_veg_curries": ["Chicken Curry", "Mutton Curry", "Fish Curry", "Prawns Curry"],
|
| 8 |
"biryani": ["Veg Biryani", "Paneer Biryani", "Chicken Biryani", "Mutton Biryani", "Fish Biryani", "Prawns Biryani"]
|
| 9 |
}
|
| 10 |
+
|
| 11 |
+
# Pairing Logic: Generate Suggestions Dynamically
|
| 12 |
+
def suggest_pairings(selected_breads, selected_curries, selected_biryani):
|
| 13 |
+
remaining_suggestions = {
|
| 14 |
"veg_curries": [],
|
| 15 |
"non_veg_curries": [],
|
| 16 |
"biryani": [],
|
| 17 |
+
"breads": []
|
| 18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# Avoid suggesting already selected categories
|
| 21 |
+
if not selected_breads:
|
| 22 |
+
remaining_suggestions["breads"] = menu["breads"]
|
| 23 |
+
if not selected_curries:
|
| 24 |
+
remaining_suggestions["veg_curries"] = menu["veg_curries"]
|
| 25 |
+
remaining_suggestions["non_veg_curries"] = menu["non_veg_curries"]
|
| 26 |
+
if not selected_biryani:
|
| 27 |
+
remaining_suggestions["biryani"] = menu["biryani"]
|
| 28 |
|
| 29 |
+
suggestions = []
|
| 30 |
+
if remaining_suggestions["veg_curries"]:
|
| 31 |
+
suggestions.append(f"Veg Curries: {', '.join(remaining_suggestions['veg_curries'])}")
|
| 32 |
+
if remaining_suggestions["non_veg_curries"]:
|
| 33 |
+
suggestions.append(f"Non-Veg Curries: {', '.join(remaining_suggestions['non_veg_curries'])}")
|
| 34 |
+
if remaining_suggestions["biryani"]:
|
| 35 |
+
suggestions.append(f"Biryani: {', '.join(remaining_suggestions['biryani'])}")
|
| 36 |
+
if remaining_suggestions["breads"]:
|
| 37 |
+
suggestions.append(f"Breads: {', '.join(remaining_suggestions['breads'])}")
|
| 38 |
|
| 39 |
+
return "\n".join(suggestions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
# Show Summary on Next Page
|
| 42 |
+
def show_summary(selected_breads, selected_curries, selected_biryani, custom_ingredients, custom_text):
|
| 43 |
+
result = "### Your Selected Items:\n\n"
|
| 44 |
+
if selected_breads:
|
| 45 |
+
result += f"**Breads:** {', '.join(selected_breads)}\n"
|
| 46 |
+
if selected_curries:
|
| 47 |
+
result += f"**Curries:** {', '.join(selected_curries)}\n"
|
| 48 |
+
if selected_biryani:
|
| 49 |
+
result += f"**Biryani:** {', '.join(selected_biryani)}\n"
|
| 50 |
+
if custom_ingredients:
|
| 51 |
+
result += f"**Custom Ingredients:** {', '.join(custom_ingredients)}\n"
|
| 52 |
+
if custom_text:
|
| 53 |
+
result += f"**Custom Dish Preferences:** {custom_text}\n"
|
| 54 |
+
return result
|
| 55 |
|
| 56 |
+
# Gradio Interface
|
|
|
|
| 57 |
with gr.Blocks() as demo:
|
| 58 |
gr.Markdown("# Dish Pairing App")
|
| 59 |
+
|
| 60 |
+
# Selections
|
| 61 |
with gr.Row():
|
| 62 |
+
bread_input = gr.CheckboxGroup(menu["breads"], label="Select Breads")
|
| 63 |
+
curry_input = gr.CheckboxGroup(menu["veg_curries"] + menu["non_veg_curries"], label="Select Curries")
|
| 64 |
+
biryani_input = gr.CheckboxGroup(menu["biryani"], label="Select Biryani")
|
| 65 |
|
| 66 |
+
# Suggestions
|
| 67 |
+
suggestions_output = gr.Textbox(label="Dynamic Pairing Suggestions", interactive=False)
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
# Customization Options
|
| 70 |
+
gr.Markdown("### Customize Your Dish")
|
| 71 |
+
custom_ingredients = gr.CheckboxGroup(
|
| 72 |
+
["Extra Cheese", "Extra Spicy", "Less Oil", "No Onions", "No Garlic"], label="Select Ingredients"
|
| 73 |
+
)
|
| 74 |
+
custom_text = gr.Textbox(label="Write Your Custom Dish Preference")
|
| 75 |
+
|
| 76 |
+
# Next Button and Summary Page
|
| 77 |
+
next_btn = gr.Button("Next")
|
| 78 |
+
summary_output = gr.Textbox(label="Summary", interactive=False)
|
| 79 |
+
|
| 80 |
+
# Dynamic Suggestions
|
| 81 |
+
bread_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output)
|
| 82 |
+
curry_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output)
|
| 83 |
+
biryani_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output)
|
| 84 |
+
|
| 85 |
+
# Navigate to Summary Page
|
| 86 |
+
next_btn.click(
|
| 87 |
+
show_summary,
|
| 88 |
+
inputs=[bread_input, curry_input, biryani_input, custom_ingredients, custom_text],
|
| 89 |
+
outputs=summary_output
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
gr.Markdown("### Your Final Selections:")
|
| 93 |
+
summary_output.render()
|
| 94 |
|
| 95 |
demo.launch()
|