yeeeeezus commited on
Commit
666805d
·
verified ·
1 Parent(s): 55e3903

static companion: in-browser MiniLM semantic search + verified aisearch index + curated catalog

Browse files
Files changed (1) hide show
  1. index.html +15 -7
index.html CHANGED
@@ -159,7 +159,7 @@ footer{padding:32px 0}
159
  </div>
160
  <p class="runtime" id="runtime">booting inference runtime…</p>
161
  <div class="progress"><i id="prog"></i></div>
162
- <div class="results" id="results"><div class="loadstate" id="loadstate">initializing…</div></div>
163
  </div>
164
  </div>
165
  </section>
@@ -289,7 +289,7 @@ document.getElementById("cards").innerHTML = MODELS.map(m=>`<div class="card">
289
  </div>`).join("");
290
 
291
  /* semantic search */
292
- const resultsEl = document.getElementById("results"), loadstate = document.getElementById("loadstate");
293
  const runtimeEl = document.getElementById("runtime"), progEl = document.getElementById("prog");
294
  let extractor=null, corpus=null;
295
 
@@ -298,8 +298,11 @@ function showAll(){
298
  }
299
  showAll();
300
 
301
- (async () => {
 
 
302
  try {
 
303
  const tf = await import("https://cdn.jsdelivr.net/npm/@huggingface/transformers@3");
304
  tf.env.allowLocalModels = false;
305
  extractor = await tf.pipeline("feature-extraction","Xenova/all-MiniLM-L6-v2",{
@@ -310,13 +313,18 @@ showAll();
310
  const out = await extractor(IDX.map(t=>`${t.n} by ${t.o}. ${t.note} ${t.e} category ${t.c}`),{pooling:"mean",normalize:true});
311
  corpus = out.tolist();
312
  progEl.style.width="100%";
313
- loadstate.parentElement.style.display="none";
 
314
  runtimeEl.textContent = "runtime: Xenova/all-MiniLM-L6-v2 · 384-dim · WASM in-browser · corpus: 21 items probed 2026-09-30";
315
  } catch(e){
316
- loadstate.textContent = "runtime failed to load — the index table below still works. ("+e.message.slice(0,120)+")";
317
- runtimeEl.textContent = "runtime error";
 
 
 
318
  }
319
- })();
 
320
 
321
  function cosine(a,b){let d=0;for(let i=0;i<a.length;i++)d+=a[i]*b[i];return d;}
322
 
 
159
  </div>
160
  <p class="runtime" id="runtime">booting inference runtime…</p>
161
  <div class="progress"><i id="prog"></i></div>
162
+ <div class="results" id="results"><div class="loadstate" id="loadstate">initializing…</div><div id="rows"></div></div>
163
  </div>
164
  </div>
165
  </section>
 
289
  </div>`).join("");
290
 
291
  /* semantic search */
292
+ const resultsEl = document.getElementById("rows"), loadstate = document.getElementById("loadstate");
293
  const runtimeEl = document.getElementById("runtime"), progEl = document.getElementById("prog");
294
  let extractor=null, corpus=null;
295
 
 
298
  }
299
  showAll();
300
 
301
+ const sleep = ms => new Promise(r=>setTimeout(r,ms));
302
+
303
+ async function boot(attempt){
304
  try {
305
+ if(attempt>0) loadstate.textContent = "retrying (attempt "+(attempt+1)+")…";
306
  const tf = await import("https://cdn.jsdelivr.net/npm/@huggingface/transformers@3");
307
  tf.env.allowLocalModels = false;
308
  extractor = await tf.pipeline("feature-extraction","Xenova/all-MiniLM-L6-v2",{
 
313
  const out = await extractor(IDX.map(t=>`${t.n} by ${t.o}. ${t.note} ${t.e} category ${t.c}`),{pooling:"mean",normalize:true});
314
  corpus = out.tolist();
315
  progEl.style.width="100%";
316
+ loadstate.style.display="none";
317
+ document.querySelector(".progress").style.display="none";
318
  runtimeEl.textContent = "runtime: Xenova/all-MiniLM-L6-v2 · 384-dim · WASM in-browser · corpus: 21 items probed 2026-09-30";
319
  } catch(e){
320
+ if(attempt < 2){ await sleep(1500*(attempt+1)); return boot(attempt+1); }
321
+ loadstate.innerHTML = "runtime failed after 3 attempts — the index table below still works.<br><button class=\"btn green\" style=\"margin-top:10px\" id=\"retryBtn\">Retry</button>";
322
+ runtimeEl.textContent = "runtime error: "+(e.message||e).toString().slice(0,110);
323
+ const rb = document.getElementById("retryBtn");
324
+ if(rb) rb.onclick = () => { loadstate.style.display=""; document.querySelector(".progress").style.display=""; progEl.style.width="0"; boot(0); };
325
  }
326
+ }
327
+ boot(0);
328
 
329
  function cosine(a,b){let d=0;for(let i=0;i<a.length;i++)d+=a[i]*b[i];return d;}
330