Fully working version at last.
Browse files- package.json +1 -1
- src/app/init-milkdown.js +4 -2
- src/app/model-slash.js +6 -6
- src/worker/boot-worker.js +8 -1
- src/worker/curated-model-list.json +2 -25
package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "localm",
|
| 3 |
-
"version": "1.1.
|
| 4 |
"description": "Chat application",
|
| 5 |
"scripts": {
|
| 6 |
"build": "esbuild src/index.js --target=es6 --bundle --sourcemap --outfile=./index.js --format=iife --external:fs --external:path --external:child_process --external:ws --external:katex/dist/katex.min.css",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "localm",
|
| 3 |
+
"version": "1.1.38",
|
| 4 |
"description": "Chat application",
|
| 5 |
"scripts": {
|
| 6 |
"build": "esbuild src/index.js --target=es6 --bundle --sourcemap --outfile=./index.js --format=iife --external:fs --external:path --external:child_process --external:ws --external:katex/dist/katex.min.css",
|
src/app/init-milkdown.js
CHANGED
|
@@ -105,8 +105,10 @@ export async function initMilkdown({
|
|
| 105 |
availableModels = entries.map(e => ({
|
| 106 |
id: e.id || e.modelId || '',
|
| 107 |
name: e.name || (e.id || e.modelId || '').split('/').pop(),
|
| 108 |
-
size:
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
}));
|
| 111 |
|
| 112 |
outputMessage('Models discovered: **' + availableModels.length + '**');
|
|
|
|
| 105 |
availableModels = entries.map(e => ({
|
| 106 |
id: e.id || e.modelId || '',
|
| 107 |
name: e.name || (e.id || e.modelId || '').split('/').pop(),
|
| 108 |
+
size:
|
| 109 |
+
((e.size_hint || '') + ' ' +
|
| 110 |
+
(e.info?.params || '')).trim(),
|
| 111 |
+
requiresAuth: e.classification === 'auth-protected' || e.requiresAuth,
|
| 112 |
}));
|
| 113 |
|
| 114 |
outputMessage('Models discovered: **' + availableModels.length + '**');
|
src/app/model-slash.js
CHANGED
|
@@ -46,7 +46,7 @@ export function createModelSlashPlugin({ getModels, onSlashCommand }) {
|
|
| 46 |
// Function to rebuild menu content
|
| 47 |
function rebuildMenu() {
|
| 48 |
menu.innerHTML = '';
|
| 49 |
-
|
| 50 |
const availableModels = getModels();
|
| 51 |
|
| 52 |
if (availableModels.length === 0) {
|
|
@@ -70,7 +70,7 @@ export function createModelSlashPlugin({ getModels, onSlashCommand }) {
|
|
| 70 |
const icon = document.createElement('span');
|
| 71 |
icon.className = 'model-icon';
|
| 72 |
icon.textContent = model.requiresAuth ? 'π' : 'π€';
|
| 73 |
-
|
| 74 |
// Create text container
|
| 75 |
const textContainer = document.createElement('div');
|
| 76 |
textContainer.className = 'model-text-container';
|
|
@@ -79,17 +79,17 @@ export function createModelSlashPlugin({ getModels, onSlashCommand }) {
|
|
| 79 |
name.className = 'name';
|
| 80 |
name.textContent = model.name;
|
| 81 |
textContainer.appendChild(name);
|
| 82 |
-
|
| 83 |
if (model.size) {
|
| 84 |
const subtitle = document.createElement('div');
|
| 85 |
subtitle.className = 'size';
|
| 86 |
subtitle.textContent = `(${model.size})`;
|
| 87 |
textContainer.appendChild(subtitle);
|
| 88 |
}
|
| 89 |
-
|
| 90 |
item.appendChild(icon);
|
| 91 |
item.appendChild(textContainer);
|
| 92 |
-
|
| 93 |
// Add auth indicator if needed
|
| 94 |
if (model.requiresAuth) {
|
| 95 |
const authSpan = document.createElement('span');
|
|
@@ -100,7 +100,7 @@ export function createModelSlashPlugin({ getModels, onSlashCommand }) {
|
|
| 100 |
|
| 101 |
modelList.appendChild(item);
|
| 102 |
});
|
| 103 |
-
|
| 104 |
menu.appendChild(modelList);
|
| 105 |
}
|
| 106 |
|
|
|
|
| 46 |
// Function to rebuild menu content
|
| 47 |
function rebuildMenu() {
|
| 48 |
menu.innerHTML = '';
|
| 49 |
+
|
| 50 |
const availableModels = getModels();
|
| 51 |
|
| 52 |
if (availableModels.length === 0) {
|
|
|
|
| 70 |
const icon = document.createElement('span');
|
| 71 |
icon.className = 'model-icon';
|
| 72 |
icon.textContent = model.requiresAuth ? 'π' : 'π€';
|
| 73 |
+
|
| 74 |
// Create text container
|
| 75 |
const textContainer = document.createElement('div');
|
| 76 |
textContainer.className = 'model-text-container';
|
|
|
|
| 79 |
name.className = 'name';
|
| 80 |
name.textContent = model.name;
|
| 81 |
textContainer.appendChild(name);
|
| 82 |
+
|
| 83 |
if (model.size) {
|
| 84 |
const subtitle = document.createElement('div');
|
| 85 |
subtitle.className = 'size';
|
| 86 |
subtitle.textContent = `(${model.size})`;
|
| 87 |
textContainer.appendChild(subtitle);
|
| 88 |
}
|
| 89 |
+
|
| 90 |
item.appendChild(icon);
|
| 91 |
item.appendChild(textContainer);
|
| 92 |
+
|
| 93 |
// Add auth indicator if needed
|
| 94 |
if (model.requiresAuth) {
|
| 95 |
const authSpan = document.createElement('span');
|
|
|
|
| 100 |
|
| 101 |
modelList.appendChild(item);
|
| 102 |
});
|
| 103 |
+
|
| 104 |
menu.appendChild(modelList);
|
| 105 |
}
|
| 106 |
|
src/worker/boot-worker.js
CHANGED
|
@@ -63,7 +63,14 @@ export function bootWorker() {
|
|
| 63 |
// run the pipeline
|
| 64 |
if (!pipe) throw new Error('pipeline not available');
|
| 65 |
self.postMessage({ id, type: 'status', status: 'inference-start', model: modelName });
|
| 66 |
-
const out = await pipe(prompt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
const text = extractText(out);
|
| 68 |
self.postMessage({ id, type: 'status', status: 'inference-done', model: modelName });
|
| 69 |
self.postMessage({ id, type: 'response', result: text });
|
|
|
|
| 63 |
// run the pipeline
|
| 64 |
if (!pipe) throw new Error('pipeline not available');
|
| 65 |
self.postMessage({ id, type: 'status', status: 'inference-start', model: modelName });
|
| 66 |
+
const out = await pipe(prompt, {
|
| 67 |
+
max_new_tokens: 250, // Increase from default
|
| 68 |
+
temperature: 0.7,
|
| 69 |
+
do_sample: true,
|
| 70 |
+
pad_token_id: pipe.tokenizer.eos_token_id,
|
| 71 |
+
return_full_text: false, // Only return the generated text
|
| 72 |
+
...options
|
| 73 |
+
});
|
| 74 |
const text = extractText(out);
|
| 75 |
self.postMessage({ id, type: 'status', status: 'inference-done', model: modelName });
|
| 76 |
self.postMessage({ id, type: 'response', result: text });
|
src/worker/curated-model-list.json
CHANGED
|
@@ -50,31 +50,6 @@
|
|
| 50 |
"notes": "Parameter count and asset layout should be verified against HF API."
|
| 51 |
}
|
| 52 |
},
|
| 53 |
-
{
|
| 54 |
-
"id": "Xenova/all-MiniLM-L6-v2",
|
| 55 |
-
"name": "all-MiniLM-L6-v2",
|
| 56 |
-
"model_type": "sentence-transformers",
|
| 57 |
-
"architectures": ["MiniLM"],
|
| 58 |
-
"classification": "encoder",
|
| 59 |
-
"confidence": "high",
|
| 60 |
-
"fetchStatus": "ok",
|
| 61 |
-
"hasTokenizer": true,
|
| 62 |
-
"hasOnnxModel": true,
|
| 63 |
-
"isTransformersJsReady": true,
|
| 64 |
-
"info": {
|
| 65 |
-
"display_name": "all-MiniLM-L6-v2 (Xenova mirror)",
|
| 66 |
-
"params": "β22M",
|
| 67 |
-
"params_count": 22000000,
|
| 68 |
-
"architecture": "MiniLM (distilled transformer)",
|
| 69 |
-
"context_window": 512,
|
| 70 |
-
"hf_url": "https://huggingface.co/Xenova/all-MiniLM-L6-v2",
|
| 71 |
-
"recommended_runtime": "transformers.js (wasm)",
|
| 72 |
-
"is_mobile_capable": true,
|
| 73 |
-
"verified": false,
|
| 74 |
-
"assumed": true,
|
| 75 |
-
"notes": "Encoder-style model (worker prefilter normally excludes sentence-transformers from generation lists)."
|
| 76 |
-
}
|
| 77 |
-
},
|
| 78 |
{
|
| 79 |
"id": "Xenova/distilgpt2",
|
| 80 |
"name": "distilgpt2",
|
|
@@ -109,6 +84,7 @@
|
|
| 109 |
"fetchStatus": "ok",
|
| 110 |
"hasTokenizer": true,
|
| 111 |
"hasOnnxModel": true,
|
|
|
|
| 112 |
"isTransformersJsReady": true,
|
| 113 |
"info": {
|
| 114 |
"display_name": "GPT-2 (Xenova mirror)",
|
|
@@ -134,6 +110,7 @@
|
|
| 134 |
"hasTokenizer": true,
|
| 135 |
"hasOnnxModel": false,
|
| 136 |
"isTransformersJsReady": false,
|
|
|
|
| 137 |
"info": {
|
| 138 |
"display_name": "Qwen-2.5 Small Instruct (Xenova mirror)",
|
| 139 |
"params": "β2.5B (estimate)",
|
|
|
|
| 50 |
"notes": "Parameter count and asset layout should be verified against HF API."
|
| 51 |
}
|
| 52 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
{
|
| 54 |
"id": "Xenova/distilgpt2",
|
| 55 |
"name": "distilgpt2",
|
|
|
|
| 84 |
"fetchStatus": "ok",
|
| 85 |
"hasTokenizer": true,
|
| 86 |
"hasOnnxModel": true,
|
| 87 |
+
"size_hint": "500Mb",
|
| 88 |
"isTransformersJsReady": true,
|
| 89 |
"info": {
|
| 90 |
"display_name": "GPT-2 (Xenova mirror)",
|
|
|
|
| 110 |
"hasTokenizer": true,
|
| 111 |
"hasOnnxModel": false,
|
| 112 |
"isTransformersJsReady": false,
|
| 113 |
+
"requiresAuth": true,
|
| 114 |
"info": {
|
| 115 |
"display_name": "Qwen-2.5 Small Instruct (Xenova mirror)",
|
| 116 |
"params": "β2.5B (estimate)",
|