Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| # Menu Data | |
| menu = { | |
| "breads": ["Roti", "Butter Naan", "Plain Naan", "Garlic Naan", "Chilly Naan"], | |
| "veg_curries": ["Paneer Butter Masala", "Kadai Paneer", "Dum Ka Paneer", "Mixed Veg Curry", "Dal Makhani"], | |
| "non_veg_curries": ["Chicken Curry", "Mutton Curry", "Fish Curry", "Prawns Curry"], | |
| "biryani": ["Veg Biryani", "Paneer Biryani", "Chicken Biryani", "Mutton Biryani", "Fish Biryani", "Prawns Biryani"] | |
| } | |
| # Pairing Logic: Generate Suggestions Dynamically | |
| def suggest_pairings(selected_breads, selected_curries, selected_biryani): | |
| remaining_suggestions = { | |
| "veg_curries": [], | |
| "non_veg_curries": [], | |
| "biryani": [], | |
| "breads": [] | |
| } | |
| # Avoid suggesting already selected categories | |
| if not selected_breads: | |
| remaining_suggestions["breads"] = menu["breads"] | |
| if not selected_curries: | |
| remaining_suggestions["veg_curries"] = menu["veg_curries"] | |
| remaining_suggestions["non_veg_curries"] = menu["non_veg_curries"] | |
| if not selected_biryani: | |
| remaining_suggestions["biryani"] = menu["biryani"] | |
| suggestions = [] | |
| if remaining_suggestions["veg_curries"]: | |
| suggestions.append(f"Veg Curries: {', '.join(remaining_suggestions['veg_curries'])}") | |
| if remaining_suggestions["non_veg_curries"]: | |
| suggestions.append(f"Non-Veg Curries: {', '.join(remaining_suggestions['non_veg_curries'])}") | |
| if remaining_suggestions["biryani"]: | |
| suggestions.append(f"Biryani: {', '.join(remaining_suggestions['biryani'])}") | |
| if remaining_suggestions["breads"]: | |
| suggestions.append(f"Breads: {', '.join(remaining_suggestions['breads'])}") | |
| return "\n".join(suggestions) | |
| # Show Summary on Next Page | |
| def show_summary(selected_breads, selected_curries, selected_biryani, custom_ingredients, custom_text): | |
| result = "### Your Selected Items:\n\n" | |
| if "Butter Naan" in selected_breads: | |
| suggestions.append("Most People Selected: Paneer Butter Masala") | |
| if selected_breads: | |
| result += f"**Breads:** {', '.join(selected_breads)}\n" | |
| if selected_curries: | |
| result += f"**Curries:** {', '.join(selected_curries)}\n" | |
| if selected_biryani: | |
| result += f"**Biryani:** {', '.join(selected_biryani)}\n" | |
| if custom_ingredients: | |
| result += f"**Custom Ingredients:** {', '.join(custom_ingredients)}\n" | |
| if custom_text: | |
| result += f"**Custom Dish Preferences:** {custom_text}\n" | |
| return result | |
| # Gradio Interface | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Dish Pairing App") | |
| # Selections | |
| with gr.Row(): | |
| bread_input = gr.CheckboxGroup(menu["breads"], label="Select Breads") | |
| curry_input = gr.CheckboxGroup(menu["veg_curries"] + menu["non_veg_curries"], label="Select Curries") | |
| biryani_input = gr.CheckboxGroup(menu["biryani"], label="Select Biryani") | |
| # Suggestions | |
| suggestions_output = gr.Textbox(label="Dynamic Pairing Suggestions", interactive=False) | |
| # Customization Options | |
| gr.Markdown("### Customize Your Dish") | |
| custom_ingredients = gr.CheckboxGroup( | |
| ["Extra Cheese", "Extra Spicy", "Less Oil", "No Onions", "No Garlic"], label="Select Ingredients" | |
| ) | |
| custom_text = gr.Textbox(label="Write Your Custom Dish Preference") | |
| # Next Button and Summary Page | |
| next_btn = gr.Button("Next") | |
| summary_output = gr.Textbox(label="Summary", interactive=False) | |
| # Dynamic Suggestions | |
| bread_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output) | |
| curry_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output) | |
| biryani_input.change(suggest_pairings, inputs=[bread_input, curry_input, biryani_input], outputs=suggestions_output) | |
| # Navigate to Summary Page | |
| next_btn.click( | |
| show_summary, | |
| inputs=[bread_input, curry_input, biryani_input, custom_ingredients, custom_text], | |
| outputs=summary_output | |
| ) | |
| gr.Markdown("### Your Final Selections:") | |
| demo.launch() | |