dindizz commited on
Commit
2f2e2ed
·
verified ·
1 Parent(s): cc39de7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
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
- result_str = f"### Best Combination of Dishes for ₹{daily_budget:.2f} in {city}:\n"
 
102
  for dish, qty in zip(selected_dishes, quantities):
103
  if qty > 1e-5:
104
- result_str += f"- **{dish}**: {qty:.2f} portions\n"
105
 
106
  # Add detailed information about each selected dish
107
- result_str += f" - Cost: ₹{nutritional_data[dish][city]} x {qty:.2f} = ₹{nutritional_data[dish][city] * qty:.2f}\n"
108
- result_str += f" - Energy: {nutritional_data[dish]['Energy (kcal)']} kcal x {qty:.2f} = {nutritional_data[dish]['Energy (kcal)'] * qty:.2f} kcal\n"
109
- result_str += f" - Protein: {nutritional_data[dish]['Protein (g)']} g x {qty:.2f} = {nutritional_data[dish]['Protein (g)'] * qty:.2f} g\n"
110
- result_str += f" - Fat: {nutritional_data[dish]['Fat (g)']} g x {qty:.2f} = {nutritional_data[dish]['Fat (g)'] * qty:.2f} g\n"
111
- result_str += f" - Carbohydrate: {nutritional_data[dish]['Carbohydrate (g)']} g x {qty:.2f} = {nutritional_data[dish]['Carbohydrate (g)'] * qty:.2f} g\n"
112
- result_str += f" - Fiber: {nutritional_data[dish]['Fiber (g)']} g x {qty:.2f} = {nutritional_data[dish]['Fiber (g)'] * qty:.2f} g\n"
113
- result_str += f" - Calcium: {nutritional_data[dish]['Calcium (mg)']} mg x {qty:.2f} = {nutritional_data[dish]['Calcium (mg)'] * qty:.2f} mg\n"
114
- result_str += f" - Iron: {nutritional_data[dish]['Iron (mg)']} mg x {qty:.2f} = {nutritional_data[dish]['Iron (mg)'] * qty:.2f} mg\n"
115
- result_str += f" - Vitamin C: {nutritional_data[dish]['Vitamin C (mg)']} mg x {qty:.2f} = {nutritional_data[dish]['Vitamin C (mg)'] * qty:.2f} mg\n\n"
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=300)
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")