fix: use 'persons' field (not 'servings') in chatToRecipe for renderRecipe compatibility
This commit is contained in:
+1
-1
@@ -3631,7 +3631,7 @@ Convert the recipe text below to a JSON object. Return ONLY the JSON, no markdow
|
|||||||
Fields:
|
Fields:
|
||||||
- title: string
|
- title: string
|
||||||
- meal: one of "colazione","pranzo","cena","dolce","succo" (infer from context, default "pranzo")
|
- 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
|
- prep_time: string or null
|
||||||
- cook_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}
|
- ingredients: array of {"name":"...","qty":"...","qty_number":0.0,"unit":"g|ml|pz|conf|kg|l","from_pantry":true}
|
||||||
|
|||||||
@@ -12440,6 +12440,9 @@ async function chatTransferToRecipes(btn, replyText) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const recipe = result.recipe;
|
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);
|
await saveRecipeToArchive(recipe);
|
||||||
_cachedRecipe = { meal: recipe.meal || 'pranzo', recipe };
|
_cachedRecipe = { meal: recipe.meal || 'pranzo', recipe };
|
||||||
renderRecipe(recipe);
|
renderRecipe(recipe);
|
||||||
|
|||||||
Reference in New Issue
Block a user