mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/myadhd
synced 2026-09-23 20:23:10 +00:00
feat(ai): completely implement webllm tier 3 fallback engine
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
This commit is contained in:
parent
0d562fec39
commit
5a0d7e576e
1 changed files with 29 additions and 1 deletions
|
|
@ -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');
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue