Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,21 +98,22 @@ def optimize_dishes_for_budget(city, daily_budget):
|
|
| 98 |
total_calories = sum(cal * qty for cal, qty in zip(calories, quantities))
|
| 99 |
total_protein = sum(prot * qty for prot, qty in zip(proteins, quantities))
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
for dish, qty in zip(selected_dishes, quantities):
|
| 103 |
if qty > 1e-5:
|
| 104 |
-
result_str += f"- **{dish}
|
| 105 |
|
| 106 |
# Add detailed information about each selected dish
|
| 107 |
-
result_str += f" - Cost: ₹{nutritional_data[dish][city]
|
| 108 |
-
result_str += f" - Energy: {nutritional_data[dish]['Energy (kcal)']
|
| 109 |
-
result_str += f" - Protein: {nutritional_data[dish]['Protein (g)']
|
| 110 |
-
result_str += f" - Fat: {nutritional_data[dish]['Fat (g)']
|
| 111 |
-
result_str += f" - Carbohydrate: {nutritional_data[dish]['Carbohydrate (g)']
|
| 112 |
-
result_str += f" - Fiber: {nutritional_data[dish]['Fiber (g)']
|
| 113 |
-
result_str += f" - Calcium: {nutritional_data[dish]['Calcium (mg)']
|
| 114 |
-
result_str += f" - Iron: {nutritional_data[dish]['Iron (mg)']
|
| 115 |
-
result_str += f" - Vitamin C: {nutritional_data[dish]['Vitamin C (mg)']
|
| 116 |
|
| 117 |
result_str += f"\n### Total Cost: ₹{total_cost:.2f}\n"
|
| 118 |
result_str += f"### Total Calories: {total_calories:.2f} kcal\n"
|
|
@@ -131,7 +132,7 @@ def create_interface():
|
|
| 131 |
|
| 132 |
# User inputs for city and daily budget
|
| 133 |
city_selector = gr.Dropdown(choices=cities, label="Select City")
|
| 134 |
-
budget_input = gr.Number(label="Daily Budget (₹)", value=
|
| 135 |
|
| 136 |
show_all_dishes_button = gr.Button("Show All Available Dishes")
|
| 137 |
optimize_button = gr.Button("Optimize Nutrition")
|
|
|
|
| 98 |
total_calories = sum(cal * qty for cal, qty in zip(calories, quantities))
|
| 99 |
total_protein = sum(prot * qty for prot, qty in zip(proteins, quantities))
|
| 100 |
|
| 101 |
+
# Create the summary of the budget allocation
|
| 102 |
+
result_str = f"### For ₹{daily_budget:.2f}, you can have:\n"
|
| 103 |
for dish, qty in zip(selected_dishes, quantities):
|
| 104 |
if qty > 1e-5:
|
| 105 |
+
result_str += f"- **{qty:.2f} portions of {dish}** at ₹{nutritional_data[dish][city]} per portion\n"
|
| 106 |
|
| 107 |
# Add detailed information about each selected dish
|
| 108 |
+
result_str += f" - Total Cost: ₹{nutritional_data[dish][city] * qty:.2f}\n"
|
| 109 |
+
result_str += f" - Total Energy: {nutritional_data[dish]['Energy (kcal)'] * qty:.2f} kcal\n"
|
| 110 |
+
result_str += f" - Total Protein: {nutritional_data[dish]['Protein (g)'] * qty:.2f} g\n"
|
| 111 |
+
result_str += f" - Total Fat: {nutritional_data[dish]['Fat (g)'] * qty:.2f} g\n"
|
| 112 |
+
result_str += f" - Total Carbohydrate: {nutritional_data[dish]['Carbohydrate (g)'] * qty:.2f} g\n"
|
| 113 |
+
result_str += f" - Total Fiber: {nutritional_data[dish]['Fiber (g)'] * qty:.2f} g\n"
|
| 114 |
+
result_str += f" - Total Calcium: {nutritional_data[dish]['Calcium (mg)'] * qty:.2f} mg\n"
|
| 115 |
+
result_str += f" - Total Iron: {nutritional_data[dish]['Iron (mg)'] * qty:.2f} mg\n"
|
| 116 |
+
result_str += f" - Total Vitamin C: {nutritional_data[dish]['Vitamin C (mg)'] * qty:.2f} mg\n\n"
|
| 117 |
|
| 118 |
result_str += f"\n### Total Cost: ₹{total_cost:.2f}\n"
|
| 119 |
result_str += f"### Total Calories: {total_calories:.2f} kcal\n"
|
|
|
|
| 132 |
|
| 133 |
# User inputs for city and daily budget
|
| 134 |
city_selector = gr.Dropdown(choices=cities, label="Select City")
|
| 135 |
+
budget_input = gr.Number(label="Daily Budget (₹)", value=500)
|
| 136 |
|
| 137 |
show_all_dishes_button = gr.Button("Show All Available Dishes")
|
| 138 |
optimize_button = gr.Button("Optimize Nutrition")
|