fix: use 'persons' field (not 'servings') in chatToRecipe for renderRecipe compatibility

This commit is contained in:
dadaloop82
2026-05-10 14:54:29 +00:00
parent 06cba1ea71
commit 2f04543de3
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -3631,7 +3631,7 @@ Convert the recipe text below to a JSON object. Return ONLY the JSON, no markdow
Fields:
- title: string
- meal: one of "colazione","pranzo","cena","dolce","succo" (infer from context, default "pranzo")
- servings: integer (default 2 if not mentioned)
- persons: integer (number of servings/people, default 2 if not mentioned)
- prep_time: string or null
- cook_time: string or null
- ingredients: array of {"name":"...","qty":"...","qty_number":0.0,"unit":"g|ml|pz|conf|kg|l","from_pantry":true}
+3
View File
@@ -12440,6 +12440,9 @@ async function chatTransferToRecipes(btn, replyText) {
return;
}
const recipe = result.recipe;
// Normalize field names: renderRecipe expects `persons`, Gemini might return `servings`
if (!recipe.persons && recipe.servings) recipe.persons = recipe.servings;
if (!recipe.persons) recipe.persons = 2;
await saveRecipeToArchive(recipe);
_cachedRecipe = { meal: recipe.meal || 'pranzo', recipe };
renderRecipe(recipe);