s
This commit is contained in:
@@ -101,8 +101,8 @@
|
||||
</div>
|
||||
<div id="chat" class="chat-container">
|
||||
<div class="msg ai shadow">
|
||||
<h5 class="fw-bold text-primary">System Online.</h5>
|
||||
Staple-scaling protocol active. All meal plans are calculated for exact mathematical compliance.
|
||||
<h5 class="fw-bold text-primary">Precision Audit Active.</h5>
|
||||
Calorie hallucination protection is engaged. Using strict USDA-aligned reference values.
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
@@ -172,24 +172,20 @@
|
||||
const text = custom === 'GENERATE_SHOPPING_LIST' ? "GENERATE_SHOPPING_LIST" : (custom || input.value);
|
||||
if(!text) return;
|
||||
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">Calculating exact portions...</div>`;
|
||||
const id = 'ai-'+Date.now(); box.innerHTML += `<div id="${id}" class="msg ai shadow">Auditing ingredient density...</div>`;
|
||||
box.scrollTop = box.scrollHeight;
|
||||
|
||||
const sysPrompt = {role:"system", content: `Expert Dietitian. TARGET: ${targetKcal} kcal.
|
||||
|
||||
STRICT CALORIE ARCHITECTURE:
|
||||
1. NO RECOMMENDATIONS AT THE END. You must NEVER finish with "to meet your goal, add X." All calories must be ALREADY in the table.
|
||||
2. MANDATORY STAPLE SCALING: If the sum is below ${targetKcal}, increase the RAW weight of Rice, Oats, Bread, or Meat (e.g., 100g -> 350g) within the tables until the total is EXACT.
|
||||
3. MATHEMATICAL LOCK: Ingredient calories must sum to 'Meal Total', and all 'Meal Totals' must sum to EXACTLY ${targetKcal}. No exceptions.
|
||||
4. No hallucinations. I am checking the math for every row.
|
||||
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.
|
||||
|
||||
FORMAT:
|
||||
### [Day]
|
||||
#### [Meal Name]
|
||||
| Ingredient | Weight (RAW) | Calories | P(g) | C(g) | F(g) |
|
||||
Meal Total: [Kcal] | [P] | [C] | [F]
|
||||
|
||||
**Daily Total: [Sum] kcal** (Must be ${targetKcal})`};
|
||||
| Ingredient | Weight (RAW) | Calories | P | C | F |
|
||||
Daily Total: [Exact Sum] kcal (Must equal ${targetKcal})`};
|
||||
|
||||
conversationHistory.push({role: "user", content: text});
|
||||
try {
|
||||
@@ -198,7 +194,7 @@
|
||||
body: JSON.stringify({
|
||||
model:"llama-3.3-70b-versatile",
|
||||
messages:[sysPrompt, ...conversationHistory],
|
||||
temperature: 0.0 // Forced precision
|
||||
temperature: 0.0
|
||||
})
|
||||
});
|
||||
const d = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user