0
-Target Calories
+Daily Calorie Target
0.0L
- Daily Hydration + Daily Hydration
-
-
-
-
+
PROTEIN
0g
- 0g
CARBS
0g
- 0g
FATS
0g
+
+ 0g
+
P
0g
+ 0g
C
0g
+ 0g
F
0g
0g
-
-
+
+
+
-
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 Ready.
+ The nutritional database is online. I can now handle varied ingredients, specific protein requests, and precise caloric targets.
-
+
Reset successful. Standing by.
`;
- conversationHistory = []; update();
+ document.getElementById('pG').innerText = "0g"; document.getElementById('cG').innerText = "0g"; document.getElementById('fG').innerText = "0g";
+ document.getElementById('chat').innerHTML = `System Reset.
`;
+ 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' ? "Sum all ingredients from the plan into a weekly shopping list." : (custom || input.value);
+ const text = custom === 'GENERATE_SHOPPING_LIST' ? "Provide a full shopping list based on the plan above." : (custom || input.value);
if(!text) return;
if(!custom) { box.innerHTML += `${text}
`; input.value=""; }
- const id = 'ai-'+Date.now(); box.innerHTML += `Generating meal architecture...
`;
+ const id = 'ai-'+Date.now(); box.innerHTML += `Consulting database...
`;
box.scrollTop = box.scrollHeight;
- 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.`};
+ const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal.
+ 1. MATH: 100g RAW Brown Rice = 360 kcal. 100g RAW Oats = 380 kcal.
+ 2. VERSATILITY: You have full freedom to use salmon, steak, eggs, avocado, olive oil, and diverse veggies. Do not repeat chicken/rice endlessly.
+ 3. CUSTOMER PREFERENCE: Prioritize high-protein or specific ingredients if requested.
+ 4. ACCURACY: Scale portion grams (e.g., 140g, 90g) to ensure the total is EXACTLY ${targetKcal} kcal.
+ Output: Markdown tables with Weight (RAW), Calories, P, C, F.`};
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.2 })
+ body: JSON.stringify({ model:"llama-3.3-70b-versatile", messages:[sysPrompt, ...conversationHistory], temperature: 0.15 })
});
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 = "API Error."; }
+ } catch(e) { document.getElementById(id).innerText = "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: '78%' }
+ options: { plugins: { legend: { display: false } }, cutout: '75%' }
});
}