s
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
<title>NutriAI Elite v26.0</title>
|
<title>NutriAI Elite v26.3</title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
@@ -11,102 +11,102 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||||
<style>
|
<style>
|
||||||
:root { --primary: #3b82f6; --bg: #020617; --sidebar: #0f172a; --card: #1e293b; --accent: #60a5fa; --text: #ffffff; }
|
:root { --primary: #3b82f6; --bg: #020617; --sidebar: #0f172a; --card: #1e293b; --accent: #60a5fa; --text: #ffffff; }
|
||||||
body.theme-dark { --bg: #020617; --sidebar: #0f172a; --primary: #3b82f6; }
|
|
||||||
body.theme-emerald { --bg: #064e3b; --sidebar: #065f46; --primary: #10b981; }
|
|
||||||
body.theme-midnight { --bg: #1e1b4b; --sidebar: #312e81; --primary: #818cf8; }
|
|
||||||
body.theme-titanium { --bg: #111827; --sidebar: #1f2937; --primary: #94a3b8; --card: #374151; --accent: #f8fafc; }
|
|
||||||
body { background-color: var(--bg); color: var(--text); font-family: 'Outfit', sans-serif; height: 100dvh; overflow: hidden; transition: 0.3s; }
|
body { background-color: var(--bg); color: var(--text); font-family: 'Outfit', sans-serif; height: 100dvh; overflow: hidden; transition: 0.3s; }
|
||||||
.main-wrapper { display: flex; height: 100dvh; flex-direction: row; }
|
.main-wrapper { display: flex; height: 100dvh; flex-direction: row; }
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
.main-wrapper { flex-direction: column; overflow-y: auto; height: auto; }
|
.main-wrapper { flex-direction: column; overflow-y: auto; height: auto; }
|
||||||
.sidebar { width: 100% !important; height: auto !important; border-right: none !important; }
|
.sidebar { width: 360px !important; height: auto !important; border-right: none !important; margin: 0 auto; }
|
||||||
.chat-section { height: 600px !important; }
|
.chat-section { height: 700px !important; }
|
||||||
body { overflow-y: auto; }
|
body { overflow-y: auto; }
|
||||||
}
|
}
|
||||||
.sidebar { width: 360px; background: var(--sidebar); border-right: 1px solid rgba(255,255,255,0.1); padding: 1.5rem; overflow-y: auto; flex-shrink: 0; }
|
.sidebar { width: 360px; background: var(--sidebar); border-right: 1px solid rgba(255,255,255,0.1); padding: 1.5rem; overflow-y: auto; flex-shrink: 0; }
|
||||||
.chat-section { flex-grow: 1; display: flex; flex-direction: column; background: rgba(0,0,0,0.2); position: relative; }
|
.chat-section { flex-grow: 1; display: flex; flex-direction: column; background: rgba(0,0,0,0.2); position: relative; }
|
||||||
.label-pro { color: var(--accent); font-weight: 800; font-size: 0.75rem; text-transform: uppercase; margin-bottom: 5px; display: block; }
|
.label-pro { color: var(--accent); font-weight: 800; font-size: 0.75rem; text-transform: uppercase; margin-bottom: 5px; display: block; }
|
||||||
.glass-input { background: #fff !important; color: #000 !important; border: 3px solid var(--primary) !important; border-radius: 12px; font-weight: 800 !important; }
|
.glass-input { background: #fff !important; color: #000 !important; border: 3px solid var(--primary) !important; border-radius: 8px; font-weight: 800 !important; height: 45px; }
|
||||||
.stat-panel { background: linear-gradient(145deg, var(--primary), #1e3a8a); border-radius: 20px; padding: 1rem; margin: 10px 0; text-align: center; }
|
.stat-panel { background: linear-gradient(145deg, var(--primary), #1e3a8a); border-radius: 15px; padding: 1.5rem; margin: 15px 0; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.3); }
|
||||||
.water-hub { background: rgba(59, 130, 246, 0.1); border: 2px solid var(--primary); border-radius: 15px; padding: 12px; margin: 10px 0; text-align: center; }
|
.water-hub { background: rgba(59, 130, 246, 0.1); border: 2px solid var(--primary); border-radius: 15px; padding: 15px; margin: 10px 0; text-align: center; }
|
||||||
.macro-hub { background: rgba(255,255,255,0.05); border-radius: 20px; padding: 15px; margin-top: 10px; }
|
.macro-hub { background: rgba(255,255,255,0.05); border-radius: 20px; padding: 20px; margin-top: 10px; border: 1px solid rgba(255,255,255,0.1); }
|
||||||
.chat-container { flex-grow: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; }
|
.chat-container { flex-grow: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
|
||||||
.msg { padding: 1.2rem; border-radius: 1.2rem; margin-bottom: 1rem; font-size: 1rem; max-width: 95%; color: #fff !important; word-wrap: break-word; }
|
.msg { padding: 1.2rem; border-radius: 1rem; font-size: 1rem; max-width: 90%; color: #fff !important; line-height: 1.5; }
|
||||||
.ai { background: var(--card); border-left: 6px solid var(--primary); align-self: flex-start; }
|
.ai { background: var(--card); border-left: 5px solid var(--primary); align-self: flex-start; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
|
||||||
.user { background: var(--primary); align-self: flex-end; }
|
.user { background: var(--primary); align-self: flex-end; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3); }
|
||||||
.top-ctrl { padding: 10px; display: flex; justify-content: flex-end; gap: 8px; background: rgba(0,0,0,0.3); }
|
.top-ctrl { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 10px; background: rgba(0,0,0,0.4); border-bottom: 1px solid rgba(255,255,255,0.1); }
|
||||||
.input-area { padding: 15px; background: var(--sidebar); border-top: 1px solid rgba(255,255,255,0.1); display: flex; gap: 10px; }
|
.input-area { padding: 20px; background: var(--sidebar); border-top: 1px solid rgba(255,255,255,0.1); display: flex; gap: 12px; }
|
||||||
.btn-shop { background: #f59e0b; color: #000; font-weight: 800; border: none; border-radius: 12px; padding: 0 15px; white-space: nowrap; }
|
.btn-shop { background: #f59e0b; color: #000; font-weight: 800; border: none; border-radius: 10px; padding: 0 20px; transition: 0.2s; }
|
||||||
.btn-reset { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid #ef4444; border-radius: 12px; padding: 8px; font-weight: 700; width: 100%; margin-top: 15px; }
|
.btn-shop:hover { background: #d97706; transform: translateY(-2px); }
|
||||||
table { width: 100%; display: block; overflow-x: auto; color: #fff; border-collapse: collapse; margin: 10px 0; background: rgba(0,0,0,0.2); border-radius: 8px; }
|
.btn-reset { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid #ef4444; border-radius: 10px; padding: 12px; font-weight: 700; width: 100%; margin-top: 20px; transition: 0.2s; }
|
||||||
th, td { border: 1px solid rgba(255,255,255,0.1); padding: 8px; text-align: left; min-width: 80px; }
|
.btn-reset:hover { background: rgba(239, 68, 68, 0.2); }
|
||||||
th { background: rgba(255,255,255,0.05); font-weight: 800; color: var(--accent); }
|
table { width: 100%; border-collapse: collapse; margin: 15px 0; background: rgba(0,0,0,0.3); border-radius: 10px; overflow: hidden; }
|
||||||
|
th, td { border: 1px solid rgba(255,255,255,0.1); padding: 12px; text-align: left; }
|
||||||
|
th { background: rgba(59, 130, 246, 0.2); color: var(--accent); font-weight: 800; text-transform: uppercase; font-size: 0.75rem; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-dark">
|
<body class="theme-dark">
|
||||||
|
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<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-4"><i class="fas fa-bolt text-primary"></i> NUTRI ELITE</h3>
|
||||||
<div class="row g-2">
|
<div class="row g-3">
|
||||||
<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="txtW">Current (kg)</label><input type="number" id="w" 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="txtT">Target (kg)</label><input type="number" id="t" 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" id="txtH">Height (cm)</label><input type="number" id="h" 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-6"><label class="label-pro">Age</label><input type="number" id="age" class="form-control glass-input" placeholder="--" oninput="update()"></div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<label class="label-pro">Activity</label>
|
<label class="label-pro">Activity Level</label>
|
||||||
<select id="act" class="form-select glass-input" onchange="update()">
|
<select id="act" class="form-select glass-input" onchange="update()">
|
||||||
<option value="1.2" selected>Sedentary</option>
|
<option value="" disabled selected>Select activity...</option>
|
||||||
<option value="1.375">Lightly Active</option>
|
<option value="1.2">Sedentary (Office job)</option>
|
||||||
<option value="1.55">Moderately Active</option>
|
<option value="1.375">Lightly Active (1-2 days/week)</option>
|
||||||
<option value="1.725">Very Active</option>
|
<option value="1.55">Moderately Active (3-5 days/week)</option>
|
||||||
<option value="1.9">Extra Active</option>
|
<option value="1.725">Very Active (6-7 days/week)</option>
|
||||||
|
<option value="1.9">Extra Active (Physical Job + Training)</option>
|
||||||
</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">-300 kcal</span></label>
|
<div class="d-flex justify-content-between"><label class="label-pro">Calorie Adjustment</label><span id="aggDisp" class="badge bg-primary">0 kcal</span></div>
|
||||||
<input type="range" id="agg" class="form-range" min="-1000" max="1000" step="50" value="-300" oninput="update()">
|
<input type="range" id="agg" class="form-range" min="-1000" max="1000" step="50" value="0" oninput="update()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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="stat-panel">
|
||||||
|
<h1 class="fw-bold mb-0" id="kcal">0</h1>
|
||||||
|
<p class="text-uppercase fw-bold m-0 opacity-75 small">Daily Calorie Target</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="water-hub">
|
<div class="water-hub">
|
||||||
<h2 class="fw-bold text-info mb-0" id="h2o">3.9L</h2>
|
<h2 class="fw-bold text-info mb-0" id="h2o">0.0L</h2>
|
||||||
<span class="label-pro" id="txtH2O"><i class="fas fa-droplet me-1"></i> Daily Hydration</span>
|
<span class="label-pro mb-0"><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: 140px;"></canvas>
|
||||||
<div class="row mt-2 text-center fw-bold small">
|
<div class="row mt-3 text-center fw-bold small">
|
||||||
<div class="col-4 text-info">P: <span id="pG">162g</span></div>
|
<div class="col-4 text-info">P<br><span id="pG">0g</span></div>
|
||||||
<div class="col-4 text-danger">C: <span id="cG">217g</span></div>
|
<div class="col-4 text-danger">C<br><span id="cG">0g</span></div>
|
||||||
<div class="col-4 text-warning">F: <span id="fG">72g</span></div>
|
<div class="col-4 text-warning">F<br><span id="fG">0g</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-undo me-2"></i> RESET DASHBOARD</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chat-section">
|
<div class="chat-section">
|
||||||
<div class="top-ctrl">
|
<div class="top-ctrl">
|
||||||
<button id="btnMetric" class="btn btn-primary btn-sm active" onclick="setUnits('metric')">METRIC</button>
|
<button id="btnMetric" class="btn btn-primary btn-sm active px-3" onclick="setUnits('metric')">METRIC</button>
|
||||||
<button id="btnImperial" class="btn btn-outline-primary btn-sm" onclick="setUnits('imperial')">IMP</button>
|
<button id="btnImperial" class="btn btn-outline-primary btn-sm px-3" onclick="setUnits('imperial')">IMP</button>
|
||||||
<div class="dropdown">
|
<button class="btn btn-dark btn-sm rounded-circle" style="width:32px; height:32px;"><i class="fas fa-palette"></i></button>
|
||||||
<button class="btn btn-light btn-sm rounded-pill px-3" data-bs-toggle="dropdown"><i class="fas fa-palette"></i></button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-end shadow">
|
|
||||||
<li><a class="dropdown-item" href="#" onclick="setTheme('dark')">Onyx</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#" onclick="setTheme('emerald')">Emerald</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#" onclick="setTheme('midnight')">Midnight</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#" onclick="setTheme('titanium')">Titanium</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</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">Biometric Audit Engaged.</h5>
|
<h5 class="fw-bold text-primary">System Ready.</h5>
|
||||||
I have corrected the nutritional database. Hallucinations regarding rice and oat density have been restricted.
|
The nutritional database has been audited. I have locked the caloric density of key ingredients (Brown Rice, Oats) to prevent math hallucinations. Please enter your biometrics to begin.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<div class="input-group input-group-lg flex-grow-1">
|
<div class="input-group input-group-lg flex-grow-1">
|
||||||
<input type="text" id="uIn" class="form-control bg-dark text-white border-primary" placeholder="Type and press ENTER..." onkeydown="if(event.key === 'Enter') talk()">
|
<input type="text" id="uIn" class="form-control bg-dark text-white border-primary" placeholder="Ask for a meal plan..." onkeydown="if(event.key === 'Enter') talk()">
|
||||||
<button class="btn btn-primary" onclick="talk()"><i class="fas fa-paper-plane"></i></button>
|
<button class="btn btn-primary" onclick="talk()"><i class="fas fa-paper-plane"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-shop shadow-sm" onclick="talk('GENERATE_SHOPPING_LIST')">
|
<button class="btn-shop shadow-sm" onclick="talk('GENERATE_SHOPPING_LIST')">
|
||||||
@@ -116,13 +116,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
let isMetric = true, mChart, conversationHistory = [];
|
let isMetric = true, mChart, conversationHistory = [];
|
||||||
const API = "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";
|
const API = "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";
|
||||||
|
|
||||||
function setTheme(t) { document.body.className = 'theme-' + t; }
|
|
||||||
|
|
||||||
function setUnits(mode) {
|
function setUnits(mode) {
|
||||||
if((mode==='metric' && !isMetric) || (mode==='imperial' && isMetric)) {
|
if((mode==='metric' && !isMetric) || (mode==='imperial' && isMetric)) {
|
||||||
isMetric = !isMetric;
|
isMetric = !isMetric;
|
||||||
@@ -130,11 +127,11 @@
|
|||||||
if(w.value) w.value = isMetric ? (w.value/2.205).toFixed(0) : (w.value*2.205).toFixed(0);
|
if(w.value) w.value = isMetric ? (w.value/2.205).toFixed(0) : (w.value*2.205).toFixed(0);
|
||||||
if(t.value) t.value = isMetric ? (t.value/2.205).toFixed(0) : (t.value*2.205).toFixed(0);
|
if(t.value) t.value = isMetric ? (t.value/2.205).toFixed(0) : (t.value*2.205).toFixed(0);
|
||||||
if(h.value) h.value = isMetric ? (h.value*2.54).toFixed(0) : (h.value/2.54).toFixed(0);
|
if(h.value) h.value = isMetric ? (h.value*2.54).toFixed(0) : (h.value/2.54).toFixed(0);
|
||||||
document.getElementById('txtW').innerText = isMetric ? "Weight (kg)" : "Weight (lb)";
|
document.getElementById('txtW').innerText = isMetric ? "Current (kg)" : "Current (lb)";
|
||||||
document.getElementById('txtT').innerText = isMetric ? "Target (kg)" : "Target (lb)";
|
document.getElementById('txtT').innerText = isMetric ? "Target (kg)" : "Target (lb)";
|
||||||
document.getElementById('txtH').innerText = isMetric ? "Height (cm)" : "Height (in)";
|
document.getElementById('txtH').innerText = isMetric ? "Height (cm)" : "Height (in)";
|
||||||
document.getElementById('btnMetric').className = isMetric ? "btn btn-primary active btn-sm" : "btn btn-outline-primary btn-sm";
|
document.getElementById('btnMetric').className = isMetric ? "btn btn-primary active btn-sm px-3" : "btn btn-outline-primary btn-sm px-3";
|
||||||
document.getElementById('btnImperial').className = !isMetric ? "btn btn-primary active btn-sm" : "btn btn-outline-primary btn-sm";
|
document.getElementById('btnImperial').className = !isMetric ? "btn btn-primary active btn-sm px-3" : "btn btn-outline-primary btn-sm px-3";
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,65 +153,52 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetAll() {
|
function resetAll() {
|
||||||
['w','t','h','age','agg'].forEach(id => document.getElementById(id).value = "");
|
['w','t','h','age','agg'].forEach(id => document.getElementById(id).value = id === 'agg' ? 0 : "");
|
||||||
document.getElementById('agg').value = 0;
|
|
||||||
document.getElementById('act').selectedIndex = 0;
|
document.getElementById('act').selectedIndex = 0;
|
||||||
|
document.getElementById('kcal').innerText = "0";
|
||||||
|
document.getElementById('pG').innerText = "0g"; document.getElementById('cG').innerText = "0g"; document.getElementById('fG').innerText = "0g";
|
||||||
|
document.getElementById('chat').innerHTML = `<div class="msg ai shadow">System Reset Complete. Ready for new inputs.</div>`;
|
||||||
|
conversationHistory = [];
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function talk(custom) {
|
async function talk(custom) {
|
||||||
const box = document.getElementById('chat'), input = document.getElementById('uIn');
|
const box = document.getElementById('chat'), input = document.getElementById('uIn'), targetKcal = document.getElementById('kcal').innerText;
|
||||||
const targetKcal = document.getElementById('kcal').innerText;
|
const text = custom === 'GENERATE_SHOPPING_LIST' ? "Provide a full shopping list based on the plan above." : (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">Applying physical laws to calories...</div>`;
|
const id = 'ai-'+Date.now(); box.innerHTML += `<div id="${id}" class="msg ai shadow">Auditing nutritional math...</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. DAILY LIMIT: ${targetKcal} kcal.
|
||||||
|
STRICT MATH RULES (NO EXCEPTIONS):
|
||||||
REFERENCE TRUTH TABLE (FORBIDDEN TO IGNORE):
|
- 100g RAW Brown Rice = 360-370 kcal. (NEVER 120 or 220).
|
||||||
- Raw Brown Rice: 360-370 kcal per 100g.
|
- 100g RAW Oats = 380 kcal.
|
||||||
- Raw Oats: 380-390 kcal per 100g.
|
- 100g Chicken Breast = 165 kcal.
|
||||||
- Raw Chicken Breast: 165 kcal per 100g.
|
- You MUST double-check: Total Meal Kcal = Sum of ingredient Kcals.
|
||||||
- Whole Wheat Bread: 250 kcal per 100g (~70-90 per slice).
|
- If you need fewer calories, DECREASE the grams. Do NOT change the caloric density.
|
||||||
|
|
||||||
STRICT RULES:
|
Output: Markdown tables with Weight (RAW), Calories, P, C, F.`};
|
||||||
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 |
|
|
||||||
Meal Total: [Sum] kcal
|
|
||||||
|
|
||||||
**Daily Total: ${targetKcal} kcal**`};
|
|
||||||
|
|
||||||
conversationHistory.push({role: "user", content: text});
|
conversationHistory.push({role: "user", content: text});
|
||||||
try {
|
try {
|
||||||
const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
||||||
method: "POST", headers: {"Content-Type":"application/json", "Authorization":`Bearer ${API}`},
|
method: "POST", headers: {"Content-Type":"application/json", "Authorization":`Bearer ${API}`},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[sysPrompt, ...conversationHistory], temperature: 0.0 })
|
||||||
model:"llama-3.3-70b-versatile",
|
|
||||||
messages:[sysPrompt, ...conversationHistory],
|
|
||||||
temperature: 0.0 // Zero creativity, maximum precision.
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const d = await res.json();
|
const d = await res.json();
|
||||||
const aiMsg = d.choices[0].message.content;
|
const aiMsg = d.choices[0].message.content;
|
||||||
conversationHistory.push({role: "assistant", content: aiMsg});
|
conversationHistory.push({role: "assistant", content: aiMsg});
|
||||||
document.getElementById(id).innerHTML = marked.parse(aiMsg);
|
document.getElementById(id).innerHTML = marked.parse(aiMsg);
|
||||||
} catch(e) { document.getElementById(id).innerText = "Connection lost."; }
|
} catch(e) { document.getElementById(id).innerText = "Connection error."; }
|
||||||
box.scrollTop = box.scrollHeight;
|
box.scrollTop = box.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
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: [162*4, 217*4, 72*9], backgroundColor: ['#0dcaf0','#dc3545','#ffc107'], borderWeight:0 }] },
|
type: 'doughnut', data: { datasets: [{ data: [1,1,1], backgroundColor: ['#0dcaf0','#dc3545','#ffc107'], borderWeight:0 }] },
|
||||||
options: { plugins: { legend: { display: false } }, cutout: '75%' }
|
options: { plugins: { legend: { display: false } }, cutout: '75%' }
|
||||||
});
|
});
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user