Dieu-Sang commited on
Commit
591adee
·
1 Parent(s): 632aa1c

add meal type

Browse files
Files changed (2) hide show
  1. api/edamam_api.py +94 -82
  2. app.py +91 -69
api/edamam_api.py CHANGED
@@ -91,40 +91,71 @@ MealTypeChoices = [
91
  "Lunch",
92
  "Snack",
93
  "Teatime"]
 
 
 
 
 
 
 
 
 
 
94
 
95
  @dataclass
96
  class Recipe:
97
  name: str
98
  cuisine_type: list
99
  calories: int
100
- protein_grams: int
101
- carbs_grams: int
102
- fat_grams: int
103
  servings: int
104
  ingredients: list
105
  edamam_url: str
106
  source_url: str
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  def get_recipes(
109
  edamam_app_id: str,
110
  edamam_app_key: str,
111
- calories_min: float,
112
- calories_max: float,
113
- protein_percent: float,
114
- carbs_percent: float,
115
- fat_percent: float,
116
- query: str | None,
117
- excluded: List[str] | None,
 
 
 
 
 
 
 
 
 
 
 
118
  cuisine_type: List[str] | None = None,
119
  meal_type: List[str] | None = None,
120
- sugar_min_grams: float | None = None,
121
- sugar_max_grams: float | None = None,
122
- sodium_min_grams: float | None = None,
123
- sodium_max_grams: float | None = None,
124
- saturated_fat_min_grams: float | None = None,
125
- saturated_fat_max_grams: float | None = None,
126
- fiber_min_grams: float | None = None,
127
- fiber_max_grams: float | None = None,
128
  diet: List[str] | None = None,
129
  health: List[str] | None = None,
130
  nb_recipes: int = 1,
@@ -133,23 +164,12 @@ def get_recipes(
133
  if not edamam_app_id or not edamam_app_key:
134
  return []
135
 
136
- """Compute macronutrients in grams from percent"""
137
- protein_min_grams = round(protein_percent * calories_min / 100.0 / 4.0)
138
- protein_max_grams = round(protein_percent * calories_max / 100.0 / 4.0)
139
- carbs_min_grams = round(carbs_percent * calories_min / 100.0 / 4.0)
140
- carbs_max_grams = round(carbs_percent * calories_max / 100.0 / 4.0)
141
- fat_min_grams = round(fat_percent * calories_min / 100.0 / 9.0)
142
- fat_max_grams = round(fat_percent * calories_max / 100.0 / 9.0)
143
-
144
  params = {
145
  'type': 'any',
146
  'app_id': edamam_app_id,
147
  'app_key': edamam_app_key,
148
  'calories': f"{str(calories_min)}-{str(calories_max)}",
149
- 'nutrients[PROCNT]': f"{str(protein_min_grams)}-{str(protein_max_grams)}",
150
- 'nutrients[CHOCDF]': f"{str(carbs_min_grams)}-{str(carbs_max_grams)}",
151
- 'nutrients[FAT]': f"{str(fat_min_grams)}-{str(fat_max_grams)}",
152
- 'q': query,
153
  'excluded': excluded,
154
  'diet': diet,
155
  'health': health,
@@ -157,41 +177,14 @@ def get_recipes(
157
  'mealType': meal_type,
158
  }
159
 
160
- """Sugar"""
161
- if sugar_min_grams!=None and sugar_max_grams==None:
162
- params.update({'nutrient[SUGAR]': f"{str(sugar_min_grams)}+"})
163
- if sugar_min_grams==None and sugar_max_grams!=None:
164
- params.update({'nutrient[SUGAR]': f"{str(sugar_max_grams)}"})
165
- if sugar_min_grams!=None and sugar_max_grams!=None:
166
- params.update({'nutrient[SUGAR]': f"{str(sugar_min_grams)}-{str(sugar_max_grams)}"})
167
-
168
- """Sodium"""
169
- if sodium_min_grams!=None and sodium_max_grams==None:
170
- sodium_min_milligrams = sodium_min_grams * 1000.0
171
- params.update({'nutrient[NA]': f"{str(sodium_min_milligrams)}+"})
172
- if sodium_min_grams==None and sodium_max_grams!=None:
173
- sodium_max_milligrams = sodium_max_grams * 1000.0
174
- params.update({'nutrient[NA]': f"{str(sodium_max_milligrams)}"})
175
- if sodium_min_grams!=None and sodium_max_grams!=None:
176
- sodium_min_milligrams = sodium_min_grams * 1000.0
177
- sodium_max_milligrams = sodium_max_grams * 1000.0
178
- params.update({'nutrient[NA]': f"{str(sodium_min_milligrams)}-{str(sodium_max_milligrams)}"})
179
-
180
- """Saturated fat"""
181
- if saturated_fat_min_grams!=None and saturated_fat_max_grams==None:
182
- params.update({'nutrient[FASAT]': f"{str(saturated_fat_min_grams)}+"})
183
- if saturated_fat_min_grams==None and saturated_fat_max_grams!=None:
184
- params.update({'nutrient[FASAT]': f"{str(saturated_fat_max_grams)}"})
185
- if saturated_fat_min_grams!=None and saturated_fat_max_grams!=None:
186
- params.update({'nutrient[FASAT]': f"{str(saturated_fat_min_grams)}-{str(saturated_fat_max_grams)}"})
187
-
188
- """Fiber"""
189
- if fiber_min_grams!=None and fiber_max_grams==None:
190
- params.update({'nutrient[FIBTG]': f"{str(fiber_min_grams)}+"})
191
- if fiber_min_grams==None and fiber_max_grams!=None:
192
- params.update({'nutrient[FIBTG]': f"{str(fiber_max_grams)}"})
193
- if fiber_min_grams!=None and fiber_max_grams!=None:
194
- params.update({'nutrient[FIBTG]': f"{str(fiber_min_grams)}-{str(fiber_max_grams)}"})
195
 
196
  """Get raw recipes from edamam"""
197
  response = requests.get(url='https://api.edamam.com/api/recipes/v2', params=params)
@@ -210,9 +203,9 @@ def get_recipes(
210
  name=recipe['label'],
211
  cuisine_type=recipe['cuisineType'],
212
  calories=round(recipe['totalNutrients']['ENERC_KCAL']['quantity']/servings),
213
- protein_grams=round(recipe['totalNutrients']['PROCNT']['quantity']/servings),
214
- carbs_grams=round(recipe['totalNutrients']['CHOCDF']['quantity']/servings),
215
- fat_grams=round(recipe['totalNutrients']['FAT']['quantity']/servings),
216
  servings=servings,
217
  ingredients=recipe['ingredientLines'],
218
  edamam_url=recipe['shareAs'],
@@ -234,10 +227,10 @@ def print2string_recipe(recipe: Recipe) -> str:
234
  if recipe:
235
  string += f"********\n"
236
  string += f"Recipe: {recipe.name}\n"
237
- string += f"Calories: {recipe.calories}\n"
238
- string += f"Protein: {recipe.protein_grams}g\n"
239
- string += f"Carbs: {recipe.carbs_grams}g\n"
240
- string += f"Fat: {recipe.fat_grams}g\n"
241
  string += f"Ingredients for {recipe.servings} servings:\n"
242
  for ingredient in recipe.ingredients:
243
  string += f"- {ingredient}\n"
@@ -255,21 +248,40 @@ if __name__ == "__main__":
255
  else:
256
  edamam_app_id = input('Enter your edamam app id: ')
257
  edamam_app_key = input('Enter your edamam app key: ')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  recipes = get_recipes(
260
  edamam_app_id=edamam_app_id,
261
  edamam_app_key=edamam_app_key,
262
- calories_min=500,
263
- calories_max=700,
264
- protein_percent=30,
265
- carbs_percent=20,
266
- fat_percent=50,
267
- query="chicken",
 
 
 
268
  excluded=["sesame"],
269
- cuisine_type=[],
270
- nb_recipes=3,
271
- )
272
-
273
  for recipe in recipes:
274
  print()
275
  print(print2string_recipe(recipe))
 
91
  "Lunch",
92
  "Snack",
93
  "Teatime"]
94
+ ParamQueryString = [
95
+ {"param": 'calories', "param_query_string": 'calories'},
96
+ {"param": 'protein', "param_query_string": 'nutrients[PROCNT]'},
97
+ {"param": 'carbs', "param_query_string": 'nutrients[CHOCDF.net]'},
98
+ {"param": 'fat', "param_query_string": 'nutrients[FAT]'},
99
+ {"param": 'added_sugar', "param_query_string": 'nutrients[SUGAR.added]'},
100
+ {"param": 'sodium', "param_query_string": 'nutrients[NA]'},
101
+ {"param": 'saturated_fat', "param_query_string": 'nutrients[FASAT]'},
102
+ {"param": 'fiber', "param_query_string": 'nutrients[FIBTG]'},
103
+ ]
104
 
105
  @dataclass
106
  class Recipe:
107
  name: str
108
  cuisine_type: list
109
  calories: int
110
+ protein_g: int
111
+ carbs_g: int
112
+ fat_g: int
113
  servings: int
114
  ingredients: list
115
  edamam_url: str
116
  source_url: str
117
 
118
+ def get_param_query_string(param, param_query_string_list) -> str:
119
+ for item in param_query_string_list:
120
+ if item['param'] == param:
121
+ return item['param_query_string']
122
+ return ""
123
+
124
+ def update_params(params, param_to_update, min_val, max_val):
125
+ param_query_string = get_param_query_string(param_to_update, ParamQueryString)
126
+ if not bool(param_query_string):
127
+ print("Error: could not update params")
128
+ return
129
+ if min_val!=None and max_val==None:
130
+ params.update({param_query_string: f"{str(min_val)}+"})
131
+ if min_val==None and max_val!=None:
132
+ params.update({param_query_string: f"{str(max_val)}"})
133
+ if min_val!=None and max_val!=None:
134
+ params.update({param_query_string: f"{str(min_val)}-{str(max_val)}"})
135
+
136
  def get_recipes(
137
  edamam_app_id: str,
138
  edamam_app_key: str,
139
+ calories_min: float | None = None,
140
+ calories_max: float | None = None,
141
+ protein_min_g: float | None = None,
142
+ protein_max_g: float | None = None,
143
+ carbs_min_g: float | None = None,
144
+ carbs_max_g: float | None = None,
145
+ fat_min_g: float | None = None,
146
+ fat_max_g: float | None = None,
147
+ included: str | None = None,
148
+ excluded: List[str] | None = None,
149
+ added_sugar_min_g: float | None = None,
150
+ added_sugar_max_g: float | None = None,
151
+ sodium_min_mg: float | None = None,
152
+ sodium_max_mg: float | None = None,
153
+ saturated_fat_min_g: float | None = None,
154
+ saturated_fat_max_g: float | None = None,
155
+ fiber_min_g: float | None = None,
156
+ fiber_max_g: float | None = None,
157
  cuisine_type: List[str] | None = None,
158
  meal_type: List[str] | None = None,
 
 
 
 
 
 
 
 
159
  diet: List[str] | None = None,
160
  health: List[str] | None = None,
161
  nb_recipes: int = 1,
 
164
  if not edamam_app_id or not edamam_app_key:
165
  return []
166
 
 
 
 
 
 
 
 
 
167
  params = {
168
  'type': 'any',
169
  'app_id': edamam_app_id,
170
  'app_key': edamam_app_key,
171
  'calories': f"{str(calories_min)}-{str(calories_max)}",
172
+ 'q': included,
 
 
 
173
  'excluded': excluded,
174
  'diet': diet,
175
  'health': health,
 
177
  'mealType': meal_type,
178
  }
179
 
180
+ update_params(params, 'calories', calories_min, calories_max)
181
+ update_params(params, 'protein', protein_min_g, protein_max_g)
182
+ update_params(params, 'carbs', carbs_min_g, carbs_max_g)
183
+ update_params(params, 'fat', fat_min_g, fat_max_g)
184
+ update_params(params, 'added_sugar', added_sugar_min_g, added_sugar_max_g)
185
+ update_params(params, 'sodium', sodium_min_mg, sodium_max_mg)
186
+ update_params(params, 'saturated_fat', saturated_fat_min_g, saturated_fat_max_g)
187
+ update_params(params, 'fiber', fiber_min_g, fiber_max_g)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
  """Get raw recipes from edamam"""
190
  response = requests.get(url='https://api.edamam.com/api/recipes/v2', params=params)
 
203
  name=recipe['label'],
204
  cuisine_type=recipe['cuisineType'],
205
  calories=round(recipe['totalNutrients']['ENERC_KCAL']['quantity']/servings),
206
+ protein_g=round(recipe['totalNutrients']['PROCNT']['quantity']/servings),
207
+ carbs_g=round(recipe['totalNutrients']['CHOCDF']['quantity']/servings),
208
+ fat_g=round(recipe['totalNutrients']['FAT']['quantity']/servings),
209
  servings=servings,
210
  ingredients=recipe['ingredientLines'],
211
  edamam_url=recipe['shareAs'],
 
227
  if recipe:
228
  string += f"********\n"
229
  string += f"Recipe: {recipe.name}\n"
230
+ string += f"Calories: {recipe.calories}kcal\n"
231
+ string += f"Protein: {recipe.protein_g}g\n"
232
+ string += f"Carbs: {recipe.carbs_g}g\n"
233
+ string += f"Fat: {recipe.fat_g}g\n"
234
  string += f"Ingredients for {recipe.servings} servings:\n"
235
  for ingredient in recipe.ingredients:
236
  string += f"- {ingredient}\n"
 
248
  else:
249
  edamam_app_id = input('Enter your edamam app id: ')
250
  edamam_app_key = input('Enter your edamam app key: ')
251
+
252
+ """Compute macronutrients in grams from percent"""
253
+ calories = 700
254
+ protein_min_percent = 10
255
+ protein_max_percent = 35
256
+ carbs_min_percent = 45
257
+ carbs_max_percent = 65
258
+ fat_min_percent = 10
259
+ fat_max_percent = 25
260
+
261
+ calories_div_100_div_4 = calories / 100.0 / 4.0
262
+ calories_div_100_div_9 = calories / 100.0 / 9.0
263
+ protein_min_g = round(protein_min_percent * calories_div_100_div_4)
264
+ protein_max_g = round(protein_max_percent * calories_div_100_div_4)
265
+ carbs_min_g = round(carbs_min_percent * calories_div_100_div_4)
266
+ carbs_max_g = round(carbs_max_percent * calories_div_100_div_4)
267
+ fat_min_g = round(fat_min_percent * calories_div_100_div_9)
268
+ fat_max_g = round(fat_max_percent * calories_div_100_div_9)
269
 
270
  recipes = get_recipes(
271
  edamam_app_id=edamam_app_id,
272
  edamam_app_key=edamam_app_key,
273
+ calories_min=None,
274
+ calories_max=calories,
275
+ protein_min_g=protein_min_g,
276
+ protein_max_g=protein_max_g,
277
+ carbs_min_g=carbs_min_g,
278
+ carbs_max_g=carbs_max_g,
279
+ fat_min_g=fat_min_g,
280
+ fat_max_g=fat_max_g,
281
+ included="chicken",
282
  excluded=["sesame"],
283
+ nb_recipes=5)
284
+
 
 
285
  for recipe in recipes:
286
  print()
287
  print(print2string_recipe(recipe))
app.py CHANGED
@@ -15,51 +15,69 @@ def search_recipes(
15
  edamam_app_key: str,
16
  calories_min: float,
17
  calories_max: float,
18
- protein_percent: float,
19
- carbs_percent: float,
20
- fat_percent: float,
 
 
 
21
  included: str | None,
22
  excluded: str | None,
23
- cuisine_type: List[str] | None,
24
- meal_type: List[str] | None,
25
- sugar_min_grams: float | None = None,
26
- sugar_max_grams: float | None = None,
27
- sodium_min_grams: float | None = None,
28
- sodium_max_grams: float | None = None,
29
- saturated_fat_min_grams: float | None = None,
30
- saturated_fat_max_grams: float | None = None,
31
- fiber_min_grams: float | None = None,
32
- fiber_max_grams: float | None = None,
33
  nb_recipes: int = 1
34
  ) -> str:
35
- recipes = edamam_api.get_recipes(
36
- edamam_app_id=edamam_app_id,
37
- edamam_app_key=edamam_app_key,
38
- calories_min=calories_min,
39
- calories_max=calories_max,
40
- protein_percent=protein_percent,
41
- carbs_percent=carbs_percent,
42
- fat_percent=fat_percent,
43
- query=included,
44
- excluded=make_string_list(excluded),
45
- cuisine_type=cuisine_type,
46
- meal_type=meal_type,
47
- sugar_min_grams=sugar_min_grams,
48
- sugar_max_grams=sugar_max_grams,
49
- sodium_min_grams=sodium_min_grams,
50
- sodium_max_grams=sodium_max_grams,
51
- saturated_fat_min_grams=saturated_fat_min_grams,
52
- saturated_fat_max_grams=saturated_fat_max_grams,
53
- fiber_min_grams=fiber_min_grams,
54
- fiber_max_grams=fiber_max_grams,
55
- nb_recipes=nb_recipes
56
- )
57
-
58
- recipes_text = f""
59
- for recipe in recipes:
60
- recipes_text += "\n"
61
- recipes_text += edamam_api.print2string_recipe(recipe)
62
- return recipes_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  with gr.Blocks(title="Get Your Recipes") as demo:
65
 
@@ -69,12 +87,25 @@ with gr.Blocks(title="Get Your Recipes") as demo:
69
  app_id = gr.Textbox(label="Edamam app id")
70
  app_key = gr.Textbox(label="Edamam app key")
71
  with gr.Row():
72
- calories_min = gr.Number(value=500, label="Calorie need MIN")
73
- calories_max = gr.Number(value=700, label="Calorie need MAX")
 
 
74
  with gr.Row():
75
- protein_percent = gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Protein need (%)")
76
- carbs_percent = gr.Slider(minimum=0, maximum=100, value=25, step=1, label="Carbs need (%)")
77
- fat_percent = gr.Slider(minimum=0, maximum=100, value=35, step=1, label="Fat need (%)")
 
 
 
 
 
 
 
 
 
 
 
78
  with gr.Row():
79
  included = gr.Textbox(value="chicken", label="Included ingredients (enter items separated by commas)")
80
  excluded = gr.Textbox(value="sesame", label="Excluded ingredients (enter items separated by commas)")
@@ -82,18 +113,6 @@ with gr.Blocks(title="Get Your Recipes") as demo:
82
  cuisine_type = gr.Dropdown(choices=edamam_api.CuisineTypeChoices, multiselect=True, label="Cuisine type")
83
  meal_type = gr.Dropdown(choices=edamam_api.MealTypeChoices, multiselect=True, label="Meal type")
84
 
85
- with gr.Row():
86
- sugar_min_grams = gr.Number(value=lambda: None, label="Sugar MIN (g)")
87
- sugar_max_grams = gr.Number(value=lambda: None, label="Sugar MAX (g)")
88
- sodium_min_grams = gr.Number(value=lambda: None, label="Sodium MIN (g)")
89
- sodium_max_grams = gr.Number(value=lambda: None, label="Sodium MAX (g)")
90
-
91
- with gr.Row():
92
- saturated_fat_min_grams = gr.Number(value=lambda: None, label="Saturated fat MIN (g)")
93
- saturated_fat_max_grams = gr.Number(value=lambda: None, label="Saturated fat MAX (g)")
94
- fiber_min_grams = gr.Number(value=lambda: None, label="Fiber MIN (g)")
95
- fiber_max_grams = gr.Number(value=lambda: None, label="Fiber MAX (g)")
96
-
97
  nb_recipes = gr.Number(value=1, label="Number of recipes")
98
 
99
  search_button = gr.Button("Search")
@@ -107,21 +126,24 @@ with gr.Blocks(title="Get Your Recipes") as demo:
107
  app_key,
108
  calories_min,
109
  calories_max,
110
- protein_percent,
111
- carbs_percent,
112
- fat_percent,
 
 
 
113
  included,
114
  excluded,
 
 
 
 
 
 
 
 
115
  cuisine_type,
116
  meal_type,
117
- sugar_min_grams,
118
- sugar_max_grams,
119
- sodium_min_grams,
120
- sodium_max_grams,
121
- saturated_fat_min_grams,
122
- saturated_fat_max_grams,
123
- fiber_min_grams,
124
- fiber_max_grams,
125
  nb_recipes
126
  ],
127
  outputs=result)
 
15
  edamam_app_key: str,
16
  calories_min: float,
17
  calories_max: float,
18
+ protein_min_percent: float,
19
+ protein_max_percent: float,
20
+ carbs_min_percent: float,
21
+ carbs_max_percent: float,
22
+ fat_min_percent: float,
23
+ fat_max_percent: float,
24
  included: str | None,
25
  excluded: str | None,
26
+ sugar_min_g: float | None = None,
27
+ sugar_max_g: float | None = None,
28
+ sodium_min_mg: float | None = None,
29
+ sodium_max_mg: float | None = None,
30
+ saturated_fat_min_g: float | None = None,
31
+ saturated_fat_max_g: float | None = None,
32
+ fiber_min_g: float | None = None,
33
+ fiber_max_g: float | None = None,
34
+ cuisine_type: List[str] | None = None,
35
+ meal_type: List[str] | None = None,
36
  nb_recipes: int = 1
37
  ) -> str:
38
+
39
+ """Compute macronutrients in grams from percent"""
40
+ calories = calories_max
41
+ calories_div_100_div_4 = calories / 100.0 / 4.0
42
+ calories_div_100_div_9 = calories / 100.0 / 9.0
43
+ protein_min_g = round(protein_min_percent * calories_div_100_div_4)
44
+ protein_max_g = round(protein_max_percent * calories_div_100_div_4)
45
+ carbs_min_g = round(carbs_min_percent * calories_div_100_div_4)
46
+ carbs_max_g = round(carbs_max_percent * calories_div_100_div_4)
47
+ fat_min_g = round(fat_min_percent * calories_div_100_div_9)
48
+ fat_max_g = round(fat_max_percent * calories_div_100_div_9)
49
+
50
+ recipes = edamam_api.get_recipes(
51
+ edamam_app_id=edamam_app_id,
52
+ edamam_app_key=edamam_app_key,
53
+ calories_min=calories_min,
54
+ calories_max=calories_max,
55
+ protein_min_g=protein_min_g,
56
+ protein_max_g=protein_max_g,
57
+ carbs_min_g=carbs_min_g,
58
+ carbs_max_g=carbs_max_g,
59
+ fat_min_g=fat_min_g,
60
+ fat_max_g=fat_max_g,
61
+ included=included,
62
+ excluded=make_string_list(excluded),
63
+ added_sugar_min_g=sugar_min_g,
64
+ added_sugar_max_g=sugar_max_g,
65
+ sodium_min_mg=sodium_min_mg,
66
+ sodium_max_mg=sodium_max_mg,
67
+ saturated_fat_min_g=saturated_fat_min_g,
68
+ saturated_fat_max_g=saturated_fat_max_g,
69
+ fiber_min_g=fiber_min_g,
70
+ fiber_max_g=fiber_max_g,
71
+ cuisine_type=cuisine_type,
72
+ meal_type=meal_type,
73
+ nb_recipes=nb_recipes
74
+ )
75
+
76
+ recipes_text = f""
77
+ for recipe in recipes:
78
+ recipes_text += "\n"
79
+ recipes_text += edamam_api.print2string_recipe(recipe)
80
+ return recipes_text
81
 
82
  with gr.Blocks(title="Get Your Recipes") as demo:
83
 
 
87
  app_id = gr.Textbox(label="Edamam app id")
88
  app_key = gr.Textbox(label="Edamam app key")
89
  with gr.Row():
90
+ calories_min = gr.Number(value=500, label="Calories min")
91
+ calories_max = gr.Number(value=700, label="Calories max")
92
+ protein_min_percent = gr.Slider(minimum=0, maximum=100, value=10, step=1, label="Protein min (%)")
93
+ protein_max_percent = gr.Slider(minimum=0, maximum=100, value=35, step=1, label="Protein max (%)")
94
  with gr.Row():
95
+ carbs_min_percent = gr.Slider(minimum=0, maximum=100, value=45, step=1, label="Carbs min (%)")
96
+ carbs_max_percent = gr.Slider(minimum=0, maximum=100, value=65, step=1, label="Carbs max (%)")
97
+ fat_min_percent = gr.Slider(minimum=0, maximum=100, value=10, step=1, label="Fat min (%)")
98
+ fat_max_percent = gr.Slider(minimum=0, maximum=100, value=25, step=1, label="Fat max (%)")
99
+ with gr.Row():
100
+ added_sugar_min_g = gr.Number(value=lambda: None, label="Added sugar min (g)")
101
+ added_sugar_max_g = gr.Number(value=lambda: None, label="Added sugar max (g)")
102
+ sodium_min_mg = gr.Number(value=lambda: None, label="Sodium min (mg)")
103
+ sodium_max_mg = gr.Number(value=lambda: None, label="Sodium max (mg)")
104
+ with gr.Row():
105
+ saturated_fat_min_g = gr.Number(value=lambda: None, label="Saturated fat min (g)")
106
+ saturated_fat_max_g = gr.Number(value=lambda: None, label="Saturated fat max (g)")
107
+ fiber_min_g = gr.Number(value=lambda: None, label="Fiber min (g)")
108
+ fiber_max_g = gr.Number(value=lambda: None, label="Fiber max (g)")
109
  with gr.Row():
110
  included = gr.Textbox(value="chicken", label="Included ingredients (enter items separated by commas)")
111
  excluded = gr.Textbox(value="sesame", label="Excluded ingredients (enter items separated by commas)")
 
113
  cuisine_type = gr.Dropdown(choices=edamam_api.CuisineTypeChoices, multiselect=True, label="Cuisine type")
114
  meal_type = gr.Dropdown(choices=edamam_api.MealTypeChoices, multiselect=True, label="Meal type")
115
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  nb_recipes = gr.Number(value=1, label="Number of recipes")
117
 
118
  search_button = gr.Button("Search")
 
126
  app_key,
127
  calories_min,
128
  calories_max,
129
+ protein_min_percent,
130
+ protein_max_percent,
131
+ carbs_min_percent,
132
+ carbs_max_percent,
133
+ fat_min_percent,
134
+ fat_max_percent,
135
  included,
136
  excluded,
137
+ added_sugar_min_g,
138
+ added_sugar_max_g,
139
+ sodium_min_mg,
140
+ sodium_max_mg,
141
+ saturated_fat_min_g,
142
+ saturated_fat_max_g,
143
+ fiber_min_g,
144
+ fiber_max_g,
145
  cuisine_type,
146
  meal_type,
 
 
 
 
 
 
 
 
147
  nb_recipes
148
  ],
149
  outputs=result)