Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ def translate_from_estonian(text):
|
|
20 |
return None
|
21 |
|
22 |
# Function to get recipes from Spoonacular API
|
23 |
-
def get_recipes(ingredients, calorie_limit, protein_limit, fat_limit
|
24 |
# Construct the API URL
|
25 |
translated_ingredients = translate_from_estonian(ingredients)
|
26 |
url = "https://api.spoonacular.com/recipes/complexSearch"
|
@@ -66,8 +66,8 @@ def get_recipes(ingredients, calorie_limit, protein_limit, fat_limit, api_key_sp
|
|
66 |
|
67 |
# Check if it meets the nutritional criteria
|
68 |
if calories <= calorie_limit and protein >= protein_limit and fat<=fat_limit:
|
69 |
-
translated_title = translate_to_estonian(recipe_detail['title']
|
70 |
-
translated_instructions = translate_to_estonian(recipe_detail['instructions']
|
71 |
|
72 |
filtered_recipes.append({
|
73 |
'name': translated_title if translated_title else recipe_detail['title'],
|
@@ -98,11 +98,7 @@ fat_limit = st.slider("Vali maksimaalne rasva kogus (g):", min_value=0, max_valu
|
|
98 |
# Button to generate recipes
|
99 |
if st.button("Palun retseptisoovitust"):
|
100 |
if ingredients:
|
101 |
-
|
102 |
-
api_key_spoonacular = SP_KEY
|
103 |
-
api_key_huggingface = HF_KEY
|
104 |
-
|
105 |
-
recipes = get_recipes(ingredients, calorie_limit, protein_limit, fat_limit, api_key_spoonacular, api_key_huggingface)
|
106 |
|
107 |
# Display the recipes
|
108 |
st.subheader("Genereerime retsepte:")
|
|
|
20 |
return None
|
21 |
|
22 |
# Function to get recipes from Spoonacular API
|
23 |
+
def get_recipes(ingredients, calorie_limit, protein_limit, fat_limit):
|
24 |
# Construct the API URL
|
25 |
translated_ingredients = translate_from_estonian(ingredients)
|
26 |
url = "https://api.spoonacular.com/recipes/complexSearch"
|
|
|
66 |
|
67 |
# Check if it meets the nutritional criteria
|
68 |
if calories <= calorie_limit and protein >= protein_limit and fat<=fat_limit:
|
69 |
+
translated_title = translate_to_estonian(recipe_detail['title'])
|
70 |
+
translated_instructions = translate_to_estonian(recipe_detail['instructions'])
|
71 |
|
72 |
filtered_recipes.append({
|
73 |
'name': translated_title if translated_title else recipe_detail['title'],
|
|
|
98 |
# Button to generate recipes
|
99 |
if st.button("Palun retseptisoovitust"):
|
100 |
if ingredients:
|
101 |
+
recipes = get_recipes(ingredients, calorie_limit, protein_limit, fat_limit)
|
|
|
|
|
|
|
|
|
102 |
|
103 |
# Display the recipes
|
104 |
st.subheader("Genereerime retsepte:")
|