From c06257bef94bdf6f799ef286680f70bbe0d56fab Mon Sep 17 00:00:00 2001 From: Ionel Andrei Cataon Date: Wed, 18 Feb 2026 17:51:35 +0200 Subject: [PATCH] s --- .../src/main/webapp/index.html | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/proiect-nutritie-java/src/main/webapp/index.html b/proiect-nutritie-java/src/main/webapp/index.html index b0b4de6..3aa5000 100644 --- a/proiect-nutritie-java/src/main/webapp/index.html +++ b/proiect-nutritie-java/src/main/webapp/index.html @@ -101,8 +101,8 @@
-
System Online.
- Staple-scaling protocol active. All meal plans are calculated for exact mathematical compliance. +
Precision Audit Active.
+ Calorie hallucination protection is engaged. Using strict USDA-aligned reference values.
@@ -172,24 +172,20 @@ const text = custom === 'GENERATE_SHOPPING_LIST' ? "GENERATE_SHOPPING_LIST" : (custom || input.value); if(!text) return; if(!custom) { box.innerHTML += `
${text}
`; input.value=""; } - const id = 'ai-'+Date.now(); box.innerHTML += `
Calculating exact portions...
`; + const id = 'ai-'+Date.now(); box.innerHTML += `
Auditing ingredient density...
`; box.scrollTop = box.scrollHeight; const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal. - STRICT CALORIE ARCHITECTURE: - 1. NO RECOMMENDATIONS AT THE END. You must NEVER finish with "to meet your goal, add X." All calories must be ALREADY in the table. - 2. MANDATORY STAPLE SCALING: If the sum is below ${targetKcal}, increase the RAW weight of Rice, Oats, Bread, or Meat (e.g., 100g -> 350g) within the tables until the total is EXACT. - 3. MATHEMATICAL LOCK: Ingredient calories must sum to 'Meal Total', and all 'Meal Totals' must sum to EXACTLY ${targetKcal}. No exceptions. - 4. No hallucinations. I am checking the math for every row. + CRITICAL MATH RULES: + 1. NO HALLUCINATION: You are forbidden from claiming (450g Oats = 600kcal). + 2. USDA LOOKUP: You must use real values (e.g., Raw Oats ~380kcal/100g, Chicken Breast ~165kcal/100g). + 3. REAL WEIGHTS: If the user needs ${targetKcal} kcal, adjust the GRAMS to match reality. Do not adjust the CALORIES to match a fake gram weight. + 4. ABSOLUTE TOTALS: Sum every row. If Daily Total != ${targetKcal}, you must re-calculate portions before answering. FORMAT: - ### [Day] - #### [Meal Name] - | Ingredient | Weight (RAW) | Calories | P(g) | C(g) | F(g) | - Meal Total: [Kcal] | [P] | [C] | [F] - - **Daily Total: [Sum] kcal** (Must be ${targetKcal})`}; + | Ingredient | Weight (RAW) | Calories | P | C | F | + Daily Total: [Exact Sum] kcal (Must equal ${targetKcal})`}; conversationHistory.push({role: "user", content: text}); try { @@ -198,7 +194,7 @@ body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[sysPrompt, ...conversationHistory], - temperature: 0.0 // Forced precision + temperature: 0.0 }) }); const d = await res.json();