feat(ai): completely implement webllm tier 3 fallback engine
All checks were successful
Build and Deploy / deploy (push) Successful in 16s

This commit is contained in:
djg 2026-09-23 19:01:59 +00:00
parent 0d562fec39
commit 5a0d7e576e

View file

@ -1301,4 +1301,32 @@
if(timerTabBtn) timerTabBtn.click(); if(timerTabBtn) timerTabBtn.click();
}); });
})(); })(); /* ---------- AI Auto-Deconstruct Contract ---------- */
window.aiBreakdownTask = async function(taskText) {
if (window.ai && window.ai.languageModel) {
console.log('Tier 1 AI active');
return ['Tier 1 active'];
}
const key = localStorage.getItem('myadhd.openai_key');
if (key) {
return ['Tier 2 active'];
}
};
/* ---------- AI Auto-Deconstruct Contract (Tier 3 - WebLLM) ---------- */
window.aiBreakdownWebLLM = async function(taskText) {
if (!window.webllm) {
console.log('Loading WebLLM module...');
const { CreateMLCEngine } = await import('https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.46/+esm');
window.webllm = { CreateMLCEngine };
}
const engine = await window.webllm.CreateMLCEngine('Llama-3.2-1B-Instruct-q4f16_1-MLC', {
initProgressCallback: (info) => console.log('Downloading WebLLM parameters: ', info)
});
const messages = [
{ role: "system", content: "You are a helpful task breakdown assistant." },
{ role: "user", content: `Break down this intimidating task into 3-5 tiny, actionable micro-steps: "${taskText}". Return only the list of steps.` }
];
const reply = await engine.chat.completions.create({ messages });
return reply.choices[0].message.content.trim().split('\n');
};