Spaces:
Runtime error
Runtime error
add meal type
Browse files- api/edamam_api.py +14 -7
- app.py +6 -4
api/edamam_api.py
CHANGED
|
@@ -84,6 +84,13 @@ CuisineTypeChoices = [
|
|
| 84 |
"Nordic",
|
| 85 |
"South American",
|
| 86 |
"South East Asian"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
@dataclass
|
| 89 |
class Recipe:
|
|
@@ -108,9 +115,8 @@ def get_recipes(
|
|
| 108 |
fat_percent: float,
|
| 109 |
query: str | None,
|
| 110 |
excluded: List[str] | None,
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
cuisine_type: List[str] | None,
|
| 114 |
sugar_min_grams: float | None = None,
|
| 115 |
sugar_max_grams: float | None = None,
|
| 116 |
sodium_min_grams: float | None = None,
|
|
@@ -119,6 +125,8 @@ def get_recipes(
|
|
| 119 |
saturated_fat_max_grams: float | None = None,
|
| 120 |
fiber_min_grams: float | None = None,
|
| 121 |
fiber_max_grams: float | None = None,
|
|
|
|
|
|
|
| 122 |
nb_recipes: int = 1,
|
| 123 |
) -> list:
|
| 124 |
|
|
@@ -146,6 +154,7 @@ def get_recipes(
|
|
| 146 |
'diet': diet,
|
| 147 |
'health': health,
|
| 148 |
'cuisineType': cuisine_type,
|
|
|
|
| 149 |
}
|
| 150 |
|
| 151 |
"""Sugar"""
|
|
@@ -257,10 +266,8 @@ if __name__ == "__main__":
|
|
| 257 |
fat_percent=50,
|
| 258 |
query="chicken",
|
| 259 |
excluded=["sesame"],
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
cuisine_type=['Asian'],
|
| 263 |
-
nb_recipes=1
|
| 264 |
)
|
| 265 |
|
| 266 |
for recipe in recipes:
|
|
|
|
| 84 |
"Nordic",
|
| 85 |
"South American",
|
| 86 |
"South East Asian"]
|
| 87 |
+
MealTypeChoices = [
|
| 88 |
+
None,
|
| 89 |
+
"Breakfast",
|
| 90 |
+
"Dinner",
|
| 91 |
+
"Lunch",
|
| 92 |
+
"Snack",
|
| 93 |
+
"Teatime"]
|
| 94 |
|
| 95 |
@dataclass
|
| 96 |
class Recipe:
|
|
|
|
| 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,
|
|
|
|
| 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,
|
| 131 |
) -> list:
|
| 132 |
|
|
|
|
| 154 |
'diet': diet,
|
| 155 |
'health': health,
|
| 156 |
'cuisineType': cuisine_type,
|
| 157 |
+
'mealType': meal_type,
|
| 158 |
}
|
| 159 |
|
| 160 |
"""Sugar"""
|
|
|
|
| 266 |
fat_percent=50,
|
| 267 |
query="chicken",
|
| 268 |
excluded=["sesame"],
|
| 269 |
+
cuisine_type=[],
|
| 270 |
+
nb_recipes=3,
|
|
|
|
|
|
|
| 271 |
)
|
| 272 |
|
| 273 |
for recipe in recipes:
|
app.py
CHANGED
|
@@ -21,6 +21,7 @@ def search_recipes(
|
|
| 21 |
included: str | None,
|
| 22 |
excluded: str | None,
|
| 23 |
cuisine_type: List[str] | None,
|
|
|
|
| 24 |
sugar_min_grams: float | None = None,
|
| 25 |
sugar_max_grams: float | None = None,
|
| 26 |
sodium_min_grams: float | None = None,
|
|
@@ -41,9 +42,8 @@ def search_recipes(
|
|
| 41 |
fat_percent=fat_percent,
|
| 42 |
query=included,
|
| 43 |
excluded=make_string_list(excluded),
|
| 44 |
-
diet=None,
|
| 45 |
-
health=None,
|
| 46 |
cuisine_type=cuisine_type,
|
|
|
|
| 47 |
sugar_min_grams=sugar_min_grams,
|
| 48 |
sugar_max_grams=sugar_max_grams,
|
| 49 |
sodium_min_grams=sodium_min_grams,
|
|
@@ -78,8 +78,9 @@ with gr.Blocks(title="Get Your Recipes") as demo:
|
|
| 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)")
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
with gr.Row():
|
| 85 |
sugar_min_grams = gr.Number(value=lambda: None, label="Sugar MIN (g)")
|
|
@@ -112,6 +113,7 @@ with gr.Blocks(title="Get Your Recipes") as demo:
|
|
| 112 |
included,
|
| 113 |
excluded,
|
| 114 |
cuisine_type,
|
|
|
|
| 115 |
sugar_min_grams,
|
| 116 |
sugar_max_grams,
|
| 117 |
sodium_min_grams,
|
|
|
|
| 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,
|
|
|
|
| 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,
|
|
|
|
| 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)")
|
| 81 |
+
with gr.Row():
|
| 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)")
|
|
|
|
| 113 |
included,
|
| 114 |
excluded,
|
| 115 |
cuisine_type,
|
| 116 |
+
meal_type,
|
| 117 |
sugar_min_grams,
|
| 118 |
sugar_max_grams,
|
| 119 |
sodium_min_grams,
|