diff --git a/proiect-nutritie-java/src/main/webapp/index.html b/proiect-nutritie-java/src/main/webapp/index.html
index 3aa5000..5c07a8d 100644
--- a/proiect-nutritie-java/src/main/webapp/index.html
+++ b/proiect-nutritie-java/src/main/webapp/index.html
@@ -49,15 +49,14 @@
@@ -157,13 +156,10 @@
}
function resetAll() {
- ['w','t','h','age','agg'].forEach(id => document.getElementById(id).value = id === 'agg' ? 0 : "");
+ ['w','t','h','age','agg'].forEach(id => document.getElementById(id).value = "");
+ document.getElementById('agg').value = 0;
document.getElementById('act').selectedIndex = 0;
- document.getElementById('kcal').innerText = "0";
- document.getElementById('h2o').innerText = isMetric ? "0.0L" : "0oz";
- document.getElementById('chat').innerHTML = `
System reset. Ready for input.
`;
- conversationHistory = [];
- if(mChart) { mChart.data.datasets[0].data = [1,1,1]; mChart.update(); }
+ update();
}
async function talk(custom) {
@@ -172,20 +168,28 @@
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 += `
Auditing ingredient density...
`;
+ const id = 'ai-'+Date.now(); box.innerHTML += `
Applying physical laws to calories...
`;
box.scrollTop = box.scrollHeight;
const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal.
- 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.
-
+ REFERENCE TRUTH TABLE (FORBIDDEN TO IGNORE):
+ - Raw Brown Rice: 360-370 kcal per 100g.
+ - Raw Oats: 380-390 kcal per 100g.
+ - Raw Chicken Breast: 165 kcal per 100g.
+ - Whole Wheat Bread: 250 kcal per 100g (~70-90 per slice).
+
+ STRICT RULES:
+ 1. NO "FAKING": If you need to hit ${targetKcal}, you must lower the WEIGHT (grams) if the calories are too high. Do NOT lie about the calories per gram.
+ 2. NO ADD-ONS: No "add a snack later" notes. Incorporate all calories into the main tables.
+ 3. TOTAL LOCK: (Meal 1 + Meal 2 + Meal 3 + Snack) MUST EQUAL EXACTLY ${targetKcal}.
+
FORMAT:
+ #### [Meal Name]
| Ingredient | Weight (RAW) | Calories | P | C | F |
- Daily Total: [Exact Sum] kcal (Must equal ${targetKcal})`};
+ Meal Total: [Sum] kcal
+
+ **Daily Total: ${targetKcal} kcal**`};
conversationHistory.push({role: "user", content: text});
try {
@@ -194,7 +198,7 @@
body: JSON.stringify({
model:"llama-3.3-70b-versatile",
messages:[sysPrompt, ...conversationHistory],
- temperature: 0.0
+ temperature: 0.0 // Zero creativity, maximum precision.
})
});
const d = await res.json();
@@ -207,10 +211,10 @@
window.onload = () => {
mChart = new Chart(document.getElementById('mChart').getContext('2d'), {
- type: 'doughnut', data: { datasets: [{ data: [1,1,1], backgroundColor: ['#0dcaf0','#dc3545','#ffc107'], borderWeight:0 }] },
+ type: 'doughnut', data: { datasets: [{ data: [162*4, 217*4, 72*9], backgroundColor: ['#0dcaf0','#dc3545','#ffc107'], borderWeight:0 }] },
options: { plugins: { legend: { display: false } }, cutout: '75%' }
});
- resetAll();
+ update();
}