This commit is contained in:
Ionel Andrei Cataon
2026-02-18 17:54:11 +02:00
parent c06257bef9
commit 8d1442616d

View File

@@ -49,15 +49,14 @@
<div class="sidebar"> <div class="sidebar">
<h3 class="fw-extrabold mb-3"><i class="fas fa-bolt text-primary"></i> NUTRI ELITE</h3> <h3 class="fw-extrabold mb-3"><i class="fas fa-bolt text-primary"></i> NUTRI ELITE</h3>
<div class="row g-2"> <div class="row g-2">
<div class="col-6"><label class="label-pro" id="txtW">Weight</label><input type="number" id="w" class="form-control glass-input" placeholder="--" oninput="update()"></div> <div class="col-6"><label class="label-pro" id="txtW">Weight (kg)</label><input type="number" id="w" class="form-control glass-input" value="110" oninput="update()"></div>
<div class="col-6"><label class="label-pro" id="txtT">Target</label><input type="number" id="t" class="form-control glass-input" placeholder="--" oninput="update()"></div> <div class="col-6"><label class="label-pro" id="txtT">Target (kg)</label><input type="number" id="t" class="form-control glass-input" value="85" oninput="update()"></div>
<div class="col-6"><label class="label-pro" id="txtH">Height</label><input type="number" id="h" class="form-control glass-input" placeholder="--" oninput="update()"></div> <div class="col-6"><label class="label-pro" id="txtH">Height (cm)</label><input type="number" id="h" class="form-control glass-input" value="176" oninput="update()"></div>
<div class="col-6"><label class="label-pro">Age</label><input type="number" id="age" class="form-control glass-input" placeholder="--" oninput="update()"></div> <div class="col-6"><label class="label-pro">Age</label><input type="number" id="age" class="form-control glass-input" value="30" oninput="update()"></div>
<div class="col-12"> <div class="col-12">
<label class="label-pro">Activity</label> <label class="label-pro">Activity</label>
<select id="act" class="form-select glass-input" onchange="update()"> <select id="act" class="form-select glass-input" onchange="update()">
<option value="" disabled selected>Select activity...</option> <option value="1.2" selected>Sedentary</option>
<option value="1.2">Sedentary</option>
<option value="1.375">Lightly Active</option> <option value="1.375">Lightly Active</option>
<option value="1.55">Moderately Active</option> <option value="1.55">Moderately Active</option>
<option value="1.725">Very Active</option> <option value="1.725">Very Active</option>
@@ -65,21 +64,21 @@
</select> </select>
</div> </div>
<div class="col-12"> <div class="col-12">
<label class="label-pro d-flex justify-content-between">Adjustment <span id="aggDisp">0 kcal</span></label> <label class="label-pro d-flex justify-content-between">Adjustment <span id="aggDisp">-300 kcal</span></label>
<input type="range" id="agg" class="form-range" min="-1000" max="1000" step="50" value="0" oninput="update()"> <input type="range" id="agg" class="form-range" min="-1000" max="1000" step="50" value="-300" oninput="update()">
</div> </div>
</div> </div>
<div class="stat-panel"><h1 class="fw-bold mb-0" id="kcal">0</h1><p class="text-uppercase fw-bold m-0 opacity-75 small">Target Calories</p></div> <div class="stat-panel"><h1 class="fw-bold mb-0" id="kcal">2166</h1><p class="text-uppercase fw-bold m-0 opacity-75 small">Target Calories</p></div>
<div class="water-hub"> <div class="water-hub">
<h2 class="fw-bold text-info mb-0" id="h2o">0.0L</h2> <h2 class="fw-bold text-info mb-0" id="h2o">3.9L</h2>
<span class="label-pro" id="txtH2O"><i class="fas fa-droplet me-1"></i> Daily Hydration</span> <span class="label-pro" id="txtH2O"><i class="fas fa-droplet me-1"></i> Daily Hydration</span>
</div> </div>
<div class="macro-hub"> <div class="macro-hub">
<canvas id="mChart" style="max-height: 120px;"></canvas> <canvas id="mChart" style="max-height: 120px;"></canvas>
<div class="row mt-2 text-center fw-bold small"> <div class="row mt-2 text-center fw-bold small">
<div class="col-4 text-info">P: <span id="pG">0g</span></div> <div class="col-4 text-info">P: <span id="pG">162g</span></div>
<div class="col-4 text-danger">C: <span id="cG">0g</span></div> <div class="col-4 text-danger">C: <span id="cG">217g</span></div>
<div class="col-4 text-warning">F: <span id="fG">0g</span></div> <div class="col-4 text-warning">F: <span id="fG">72g</span></div>
</div> </div>
</div> </div>
<button class="btn-reset" onclick="resetAll()"><i class="fas fa-sync me-2"></i> RESET SYSTEM</button> <button class="btn-reset" onclick="resetAll()"><i class="fas fa-sync me-2"></i> RESET SYSTEM</button>
@@ -101,8 +100,8 @@
</div> </div>
<div id="chat" class="chat-container"> <div id="chat" class="chat-container">
<div class="msg ai shadow"> <div class="msg ai shadow">
<h5 class="fw-bold text-primary">Precision Audit Active.</h5> <h5 class="fw-bold text-primary">Biometric Audit Engaged.</h5>
Calorie hallucination protection is engaged. Using strict USDA-aligned reference values. I have corrected the nutritional database. Hallucinations regarding rice and oat density have been restricted.
</div> </div>
</div> </div>
<div class="input-area"> <div class="input-area">
@@ -157,13 +156,10 @@
} }
function resetAll() { 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('act').selectedIndex = 0;
document.getElementById('kcal').innerText = "0"; update();
document.getElementById('h2o').innerText = isMetric ? "0.0L" : "0oz";
document.getElementById('chat').innerHTML = `<div class="msg ai shadow">System reset. Ready for input.</div>`;
conversationHistory = [];
if(mChart) { mChart.data.datasets[0].data = [1,1,1]; mChart.update(); }
} }
async function talk(custom) { async function talk(custom) {
@@ -172,20 +168,28 @@
const text = custom === 'GENERATE_SHOPPING_LIST' ? "GENERATE_SHOPPING_LIST" : (custom || input.value); const text = custom === 'GENERATE_SHOPPING_LIST' ? "GENERATE_SHOPPING_LIST" : (custom || input.value);
if(!text) return; if(!text) return;
if(!custom) { box.innerHTML += `<div class="msg user shadow-sm">${text}</div>`; input.value=""; } if(!custom) { box.innerHTML += `<div class="msg user shadow-sm">${text}</div>`; input.value=""; }
const id = 'ai-'+Date.now(); box.innerHTML += `<div id="${id}" class="msg ai shadow">Auditing ingredient density...</div>`; const id = 'ai-'+Date.now(); box.innerHTML += `<div id="${id}" class="msg ai shadow">Applying physical laws to calories...</div>`;
box.scrollTop = box.scrollHeight; box.scrollTop = box.scrollHeight;
const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal. const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal.
CRITICAL MATH RULES: REFERENCE TRUTH TABLE (FORBIDDEN TO IGNORE):
1. NO HALLUCINATION: You are forbidden from claiming (450g Oats = 600kcal). - Raw Brown Rice: 360-370 kcal per 100g.
2. USDA LOOKUP: You must use real values (e.g., Raw Oats ~380kcal/100g, Chicken Breast ~165kcal/100g). - Raw Oats: 380-390 kcal per 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. - Raw Chicken Breast: 165 kcal per 100g.
4. ABSOLUTE TOTALS: Sum every row. If Daily Total != ${targetKcal}, you must re-calculate portions before answering. - 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: FORMAT:
#### [Meal Name]
| Ingredient | Weight (RAW) | Calories | P | C | F | | 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}); conversationHistory.push({role: "user", content: text});
try { try {
@@ -194,7 +198,7 @@
body: JSON.stringify({ body: JSON.stringify({
model:"llama-3.3-70b-versatile", model:"llama-3.3-70b-versatile",
messages:[sysPrompt, ...conversationHistory], messages:[sysPrompt, ...conversationHistory],
temperature: 0.0 temperature: 0.0 // Zero creativity, maximum precision.
}) })
}); });
const d = await res.json(); const d = await res.json();
@@ -207,10 +211,10 @@
window.onload = () => { window.onload = () => {
mChart = new Chart(document.getElementById('mChart').getContext('2d'), { 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%' } options: { plugins: { legend: { display: false } }, cutout: '75%' }
}); });
resetAll(); update();
} }
</script> </script>
</body> </body>