Dawat-planner / app.py
Irsa87's picture
Update app.py
a9a48f9 verified
import gradio as gr
# Sample data for menu planning, recipes, and space arrangement with quantities
menu_database = {
"Chicken Biryani": {
"ingredients": "1 kg chicken, 500g rice, spices",
"link": "https://www.youtube.com/results?search_query=Chicken+Biryani+recipe",
"time": 90, # in minutes
"cost_per_person": 250
},
"Grilled Chicken": {
"ingredients": "1 kg chicken, spices",
"link": "https://www.youtube.com/results?search_query=Grilled+Chicken+recipe",
"time": 60, # in minutes
"cost_per_person": 200
},
"Mixed Vegetable Curry": {
"ingredients": "500g mixed vegetables, spices",
"link": "https://www.youtube.com/results?search_query=Mixed+Vegetable+Curry+recipe",
"time": 45, # in minutes
"cost_per_person": 100
},
"Fried Rice": {
"ingredients": "500g rice, vegetables, spices",
"link": "https://www.youtube.com/results?search_query=Fried+Rice+recipe",
"time": 40, # in minutes
"cost_per_person": 80
},
"Garlic Naan": {
"ingredients": "500g flour, garlic, butter",
"link": "https://www.youtube.com/results?search_query=Garlic+Naan+recipe",
"time": 30, # in minutes
"cost_per_person": 50
},
# Additional dishes
"Kheer": {
"ingredients": "1 liter milk, 100g rice, sugar",
"link": "https://www.youtube.com/results?search_query=Kheer+recipe",
"time": 60, # in minutes
"cost_per_person": 70
},
"Zarda": {
"ingredients": "500g rice, sugar, saffron, dry fruits",
"link": "https://www.youtube.com/results?search_query=Zarda+recipe",
"time": 50, # in minutes
"cost_per_person": 60
},
"Matanjan": {
"ingredients": "1 kg rice, 500g meat, spices",
"link": "https://www.youtube.com/results?search_query=Matanjan+recipe",
"time": 90, # in minutes
"cost_per_person": 90
},
"Gurr Walay Chawal": {
"ingredients": "500g rice, jaggery, spices",
"link": "https://www.youtube.com/results?search_query=Gurr+Walay+Chawal+recipe",
"time": 60, # in minutes
"cost_per_person": 80
},
"Tea": {
"ingredients": "Tea leaves, sugar, milk",
"link": "https://www.youtube.com/results?search_query=Tea+recipe",
"time": 15, # in minutes
"cost_per_person": 20
},
"Cold Drinks": {
"ingredients": "Various flavors",
"link": "https://www.youtube.com/results?search_query=Cold+Drinks+recipe",
"time": 10, # in minutes
"cost_per_person": 30
},
"Seekh Kabab": {
"ingredients": "500g minced meat, spices",
"link": "https://www.youtube.com/results?search_query=Seekh+Kabab+recipe",
"time": 45, # in minutes
"cost_per_person": 150
},
"Tikka": {
"ingredients": "500g chicken, spices",
"link": "https://www.youtube.com/results?search_query=Tikka+recipe",
"time": 40, # in minutes
"cost_per_person": 120
},
"Shami Kabab": {
"ingredients": "500g meat, lentils, spices",
"link": "https://www.youtube.com/results?search_query=Shami+Kabab+recipe",
"time": 60, # in minutes
"cost_per_person": 140
},
"Chapli Kebab": {
"ingredients": "500g minced meat, spices",
"link": "https://www.youtube.com/results?search_query=Chapli+Kebab+recipe",
"time": 50, # in minutes
"cost_per_person": 130
},
"Pulao": {
"ingredients": "500g rice, meat or vegetables, spices",
"link": "https://www.youtube.com/results?search_query=Pulao+recipe",
"time": 45, # in minutes
"cost_per_person": 100
},
"Plain Rice": {
"ingredients": "500g rice",
"link": "https://www.youtube.com/results?search_query=Plain+Rice+recipe",
"time": 30, # in minutes
"cost_per_person": 40
},
"Mutton Kari": {
"ingredients": "500g mutton, spices",
"link": "https://www.youtube.com/results?search_query=Mutton+Kari+recipe",
"time": 90, # in minutes
"cost_per_person": 250
},
"Daleem": {
"ingredients": "500g meat, lentils, spices",
"link": "https://www.youtube.com/results?search_query=Daleem+recipe",
"time": 90, # in minutes
"cost_per_person": 200
},
"Chargha": {
"ingredients": "1 whole chicken, spices",
"link": "https://www.youtube.com/results?search_query=Chargha+recipe",
"time": 120, # in minutes
"cost_per_person": 300
},
"Roast": {
"ingredients": "1 kg meat, spices",
"link": "https://www.youtube.com/results?search_query=Roast+recipe",
"time": 120, # in minutes
"cost_per_person": 350
},
"Chicken Achari": {
"ingredients": "500g chicken, pickles, spices",
"link": "https://www.youtube.com/results?search_query=Chicken+Achari+recipe",
"time": 60, # in minutes
"cost_per_person": 180
},
"Simple Salad": {
"ingredients": "Vegetables, dressing",
"link": "https://www.youtube.com/results?search_query=Simple+Salad+recipe",
"time": 10, # in minutes
"cost_per_person": 30
},
"Russian Salad": {
"ingredients": "Vegetables, mayonnaise",
"link": "https://www.youtube.com/results?search_query=Russian+Salad+recipe",
"time": 20, # in minutes
"cost_per_person": 40
},
"Fruit Chat": {
"ingredients": "Mixed fruits, chat masala",
"link": "https://www.youtube.com/results?search_query=Fruit+Chat+recipe",
"time": 15, # in minutes
"cost_per_person": 50
},
"Chana Chat": {
"ingredients": "Chickpeas, vegetables, spices",
"link": "https://www.youtube.com/results?search_query=Chana+Chat+recipe",
"time": 20, # in minutes
"cost_per_person": 40
},
"Pakora": {
"ingredients": "Vegetables, gram flour, spices",
"link": "https://www.youtube.com/results?search_query=Pakora+recipe",
"time": 30, # in minutes
"cost_per_person": 60
},
"Anda Channay": {
"ingredients": "Eggs, chickpeas, spices",
"link": "https://www.youtube.com/results?search_query=Anda+Channay+recipe",
"time": 40, # in minutes
"cost_per_person": 70
},
"Pasta": {
"ingredients": "Pasta, sauce, vegetables",
"link": "https://www.youtube.com/results?search_query=Pasta+recipe",
"time": 30, # in minutes
"cost_per_person": 80
},
"Vegetable Rolls": {
"ingredients": "Vegetables, roll sheets",
"link": "https://www.youtube.com/results?search_query=Vegetable+Rolls+recipe",
"time": 30, # in minutes
"cost_per_person": 90
},
}
def plan_party(dishes, guests, dinner_set, kids):
selected_menu = []
total_cost = 0
total_time = 0
for dish_name in dishes:
dish = menu_database[dish_name]
selected_menu.append((dish_name, dish["ingredients"]))
total_cost += dish["cost_per_person"] * guests
total_time += dish["time"]
# Calculate ingredient quantities for 4 persons
quantities = {}
for dish_name in dishes:
dish = menu_database[dish_name]
ingredients = dish["ingredients"]
quantity = ingredients.replace("500g", f"{500 * guests // 4}g")
quantity = quantity.replace("1 kg", f"{1000 * guests // 4}g")
quantities[dish_name] = quantity
# Generate menu, quantities, and arrangement details
menu_output = "\n".join([f"{name}: {details}" for name, details in selected_menu])
quantity_output = "\n".join([f"{dish}: {details}" for dish, details in quantities.items()])
cooking_time_hours = total_time // 60
cooking_time_minutes = total_time % 60
cooking_time_output = f"Total cooking time: {cooking_time_hours} hours {cooking_time_minutes} minutes"
estimated_total_cost_output = f"Estimated total cost: PKR {total_cost}"
# Generate YouTube recipe links
recipe_links = "<br>".join([f'<a href="{menu_database[dish]["link"]}" target="_blank">{dish} Recipe</a>' for dish in dishes])
return menu_output, quantity_output, cooking_time_output, estimated_total_cost_output, recipe_links
def create_interface():
with gr.Blocks() as dawat_bot:
gr.Markdown("# Dawat Bot - Plan Your Party!")
with gr.Row():
dish_choices = gr.CheckboxGroup(label="Select Dishes", choices=list(menu_database.keys()))
with gr.Row():
guests = gr.Slider(label="Number of Guests", minimum=1, maximum=50, step=1)
dinner_set = gr.Dropdown(label="Type of Dinner Set", choices=["Porcelain", "Melamine", "Metal"])
kids = gr.Slider(label="Number of Kids", minimum=0, maximum=20, step=1)
with gr.Row():
plan_button = gr.Button("Plan Party", variant="primary")
menu_output = gr.Textbox(label="Menu for 4 Persons")
quantity_output = gr.Textbox(label="Ingredients Quantities")
cooking_time_output = gr.Textbox(label="Estimated Cooking Time")
estimated_total_cost_output = gr.Textbox(label="Estimated Total Cost")
recipe_links = gr.HTML(label="Recipe Links")
plan_button.click(
plan_party,
inputs=[dish_choices, guests, dinner_set, kids],
outputs=[menu_output, quantity_output, cooking_time_output, estimated_total_cost_output, recipe_links]
)
dawat_bot.launch(share=True, inbrowser=True)
create_interface()