MostLime commited on
Commit
4bab630
·
verified ·
1 Parent(s): 2dd287d

Update Space

Browse files
Files changed (2) hide show
  1. app.js +26 -1
  2. config.js +14 -1
app.js CHANGED
@@ -519,7 +519,9 @@ $('cfile').addEventListener('change', async (e) => { for (const f of e.target.fi
519
  });
520
  await loadLibs();
521
  await loadModel(models.find((m) => m.id === $('model').value));
522
- if (new URLSearchParams(location.search).has('smoke')) await smoke(models);
 
 
523
  else if (isCanvas()) $('ed').focus();
524
  } catch (e) {
525
  console.error(e); setStatus(`Could not start: ${e.message || e}`);
@@ -535,6 +537,29 @@ async function testImage() {
535
  g.fillStyle = '#e53935'; g.beginPath(); g.arc(160, 120, 70, 0, 2 * Math.PI); g.fill();
536
  return new File([await new Promise((ok) => cv.toBlob(ok, 'image/png'))], 'test.png', { type: 'image/png' });
537
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
538
  async function smokeCanvas(m) {
539
  const r = { model: m.id, mode: 'canvas', ok: true };
540
  $('newchat').onclick();
 
519
  });
520
  await loadLibs();
521
  await loadModel(models.find((m) => m.id === $('model').value));
522
+ const qs = new URLSearchParams(location.search);
523
+ if (qs.has('script')) await runScript(models, JSON.parse(atob(qs.get('script'))));
524
+ else if (qs.has('smoke')) await smoke(models);
525
  else if (isCanvas()) $('ed').focus();
526
  } catch (e) {
527
  console.error(e); setStatus(`Could not start: ${e.message || e}`);
 
537
  g.fillStyle = '#e53935'; g.beginPath(); g.arc(160, 120, 70, 0, 2 * Math.PI); g.fill();
538
  return new File([await new Promise((ok) => cv.toBlob(ok, 'image/png'))], 'test.png', { type: 'image/png' });
539
  }
540
+ // Scripted chats for tests (?script=base64 JSON {model, settings, convos: [[user turn, ...], ...]}): each conversation
541
+ // goes through the same path as the UI (generate()); the replies go into document.title as 'SCRIPT:{json}'.
542
+ async function runScript(models, sc) {
543
+ const out = { ok: true, model: sc.model, convos: [] };
544
+ try {
545
+ const m = models.find((x) => x.id === sc.model);
546
+ if (m !== model) await loadModel(m);
547
+ for (const turns of sc.convos) {
548
+ $('newchat').onclick();
549
+ Object.assign(S, sc.settings || {});
550
+ const c = [];
551
+ for (const t of turns) {
552
+ const u = { role: 'user', text: t, images: [] };
553
+ messages.push(u); addMsgEl(u);
554
+ await generate();
555
+ const a = messages[messages.length - 1];
556
+ c.push({ user: t, reply: a.role === 'assistant' ? tok.decode(a.ids) : null, stats: a.stats || null });
557
+ }
558
+ out.convos.push(c);
559
+ }
560
+ } catch (e) { out.ok = false; out.error = String(e && e.stack || e); }
561
+ document.title = 'SCRIPT:' + JSON.stringify(out);
562
+ }
563
  async function smokeCanvas(m) {
564
  const r = { model: m.id, mode: 'canvas', ok: true };
565
  $('newchat').onclick();
config.js CHANGED
@@ -2,9 +2,22 @@ window.LOOPMM = {
2
  ortBase: 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/',
3
  tokenizersUrl: 'https://cdn.jsdelivr.net/npm/@huggingface/tokenizers@0.1.3/dist/tokenizers.mjs',
4
  models: [
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  {
6
  "id": "chat",
7
- "label": "Chat (SFT preview)",
8
  "repo": "MostLime/loopmm-sft-preview",
9
  "rev": "817aebc47cf7ab1f976e1ade585fb8716770d92c",
10
  "mode": "chat",
 
2
  ortBase: 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/',
3
  tokenizersUrl: 'https://cdn.jsdelivr.net/npm/@huggingface/tokenizers@0.1.3/dist/tokenizers.mjs',
4
  models: [
5
+ {
6
+ "id": "chat2",
7
+ "label": "Chat: SFT v2 (newest)",
8
+ "repo": "MostLime/loopmm-sft-v2",
9
+ "rev": "e33fdea4d7f28691305a0af160936b71258ae3a5",
10
+ "mode": "chat",
11
+ "defaults": {
12
+ "temperature": 0.2,
13
+ "topP": 0.9,
14
+ "repPenalty": 1.0,
15
+ "detail": 576
16
+ }
17
+ },
18
  {
19
  "id": "chat",
20
+ "label": "Chat: SFT preview (v1)",
21
  "repo": "MostLime/loopmm-sft-preview",
22
  "rev": "817aebc47cf7ab1f976e1ade585fb8716770d92c",
23
  "mode": "chat",