From d702f3294c70e8e328849a6be064a6d216f6789c Mon Sep 17 00:00:00 2001 From: Ionel Andrei Cataon Date: Wed, 18 Feb 2026 17:18:26 +0200 Subject: [PATCH] s --- .../src/main/webapp/index.html | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/proiect-nutritie-java/src/main/webapp/index.html b/proiect-nutritie-java/src/main/webapp/index.html index 001b585..b5a2020 100644 --- a/proiect-nutritie-java/src/main/webapp/index.html +++ b/proiect-nutritie-java/src/main/webapp/index.html @@ -3,7 +3,7 @@ - NutriAI Elite v21.0 + NutriAI Elite v22.0 @@ -114,8 +114,8 @@
-
Unit Sync Active.
- Raw ingredient weights and shopping list quantities will now match your **Metric/Imperial** selection. +
System Refined.
+ Shopping lists will only be generated upon button request. All units are synced.
@@ -124,7 +124,7 @@ - @@ -184,21 +184,30 @@ async function talk(custom) { const box = document.getElementById('chat'), input = document.getElementById('uIn'); - const text = custom || input.value; if(!text) return; + const isShopReq = custom === 'GENERATE_SHOPPING_LIST'; + const text = isShopReq ? "Please generate a shopping list for the current meal plan." : (custom || input.value); + if(!text) return; + if(!custom) { box.innerHTML += `
${text}
`; input.value=""; } - const id = 'ai-'+Date.now(); box.innerHTML += `
Calculating with ${isMetric?'Metric':'Imperial'} units...
`; + const id = 'ai-'+Date.now(); box.innerHTML += `
Processing...
`; box.scrollTop = box.scrollHeight; + 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:[ - {role:"system", content: `Expert Nutritionist. Target: ${document.getElementById('kcal').innerText} kcal. SYSTEM: ${isMetric ? 'METRIC (grams, kg, liters)' : 'IMPERIAL (ounces, lbs, cups)'}. MANDATORY: Use raw weights for ALL ingredients. Provide shopping list quantities in ${isMetric ? 'grams/kilograms' : 'ounces/lbs'}. Use Markdown tables.`}, + {role:"system", content: `Expert Nutritionist. Target: ${document.getElementById('kcal').innerText} kcal. SYSTEM: ${isMetric ? 'METRIC' : 'IMPERIAL'}. + MANDATORY RULES: + 1. ALWAYS use raw weights for ingredients in meal plans. + 2. DO NOT generate a shopping list unless the user explicitly asks for one. + 3. If requested, provide shopping list quantities in ${isMetric ? 'grams/kilograms' : 'ounces/lbs'}. + 4. Use Markdown tables.`}, {role:"user", content:text} ]}) }); const d = await res.json(); document.getElementById(id).innerHTML = marked.parse(d.choices[0].message.content); - } catch(e) { document.getElementById(id).innerText = "Error syncing with coach."; } + } catch(e) { document.getElementById(id).innerText = "Connection error."; } box.scrollTop = box.scrollHeight; }