0
-Daily Calorie Target
+Target Calories
0.0L
- Daily Hydration + Daily Hydration
-
-
-
-
+
P
0g
- 0g
C
0g
- 0g
F
0g
+
+ 0g
+
PROTEIN
0g
+ 0g
CARBS
0g
+ 0g
FATS
0g
0g
-
-
-
+
+
-
System Ready.
- 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. +Biometric Intelligence Active.
+ I am ready. Please fill in your data. I can now handle custom ingredient requests, high-protein focuses, and complex variety while maintaining strict caloric math.
-
+
System Reset Complete. Ready for new inputs.
`;
- conversationHistory = [];
- update();
+ document.getElementById('chat').innerHTML = `Reset successful. Standing by.
`;
+ conversationHistory = []; update();
}
async function talk(custom) {
const box = document.getElementById('chat'), input = document.getElementById('uIn'), 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' ? "Sum all ingredients from the plan into a weekly shopping list." : (custom || input.value);
if(!text) return;
if(!custom) { box.innerHTML += `${text}
`; input.value=""; }
- const id = 'ai-'+Date.now(); box.innerHTML += `Auditing nutritional math...
`;
+ const id = 'ai-'+Date.now(); box.innerHTML += `Generating meal architecture...
`;
box.scrollTop = box.scrollHeight;
- const sysPrompt = {role:"system", content: `Expert Dietitian. DAILY LIMIT: ${targetKcal} kcal.
- STRICT MATH RULES (NO EXCEPTIONS):
- - 100g RAW Brown Rice = 360-370 kcal. (NEVER 120 or 220).
- - 100g RAW Oats = 380 kcal.
- - 100g Chicken Breast = 165 kcal.
- - You MUST double-check: Total Meal Kcal = Sum of ingredient Kcals.
- - If you need fewer calories, DECREASE the grams. Do NOT change the caloric density.
-
- Output: Markdown tables with Weight (RAW), Calories, P, C, F.`};
+ const sysPrompt = {role:"system", content: `Advanced Clinical Nutritionist. GOAL: EXACTLY ${targetKcal} kcal.
+ 1. MATH AUDIT: You MUST verify sums. 100g RAW Brown Rice = 360 kcal. 100g RAW Oats = 380 kcal.
+ 2. FOOD DIVERSITY: Use Steak, Salmon, Eggs, Avocado, Berries, Quinoa, Sweet Potato, Nut Butters. NEVER just chicken/rice unless asked.
+ 3. CUSTOMIZATION: If user asks for "Dense Protein" or "Specific Ingredients", prioritize those while scaling portions to hit ${targetKcal} kcal EXACTLY.
+ 4. STRUCTURE: Provide daily totals for P/C/F. Ensure Math checks: (P*4)+(C*4)+(F*9) = Total Kcal.`};
conversationHistory.push({role: "user", content: text});
try {
const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {
method: "POST", headers: {"Content-Type":"application/json", "Authorization":`Bearer ${API}`},
- body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[sysPrompt, ...conversationHistory], temperature: 0.0 })
+ body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[sysPrompt, ...conversationHistory], temperature: 0.2 })
});
const d = await res.json();
const aiMsg = d.choices[0].message.content;
conversationHistory.push({role: "assistant", content: aiMsg});
document.getElementById(id).innerHTML = marked.parse(aiMsg);
- } catch(e) { document.getElementById(id).innerText = "Connection error."; }
+ } catch(e) { document.getElementById(id).innerText = "API Error."; }
box.scrollTop = box.scrollHeight;
}
window.onload = () => {
mChart = new Chart(document.getElementById('mChart').getContext('2d'), {
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: '78%' }
});
}