nagasurendra commited on
Commit
f71aca9
·
verified ·
1 Parent(s): d0a9d46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -56
app.py CHANGED
@@ -1,59 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()
 
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()