maxidl commited on
Commit
6a4eb89
Β·
verified Β·
1 Parent(s): 1a66e59

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +113 -2
index.html CHANGED
@@ -5,6 +5,13 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>ellamind base-eval</title>
7
  <script src="https://cdn.plot.ly/plotly-2.35.2.min.js" charset="utf-8"></script>
 
 
 
 
 
 
 
8
  <style>
9
  * { box-sizing: border-box; margin: 0; padding: 0; }
10
  body {
@@ -343,11 +350,36 @@
343
  width: 420px;
344
  max-width: 60vw;
345
  }
346
- .merge-dataset-row input[type="text"]:focus {
 
347
  outline: none;
348
  border-color: #4361ee;
349
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
350
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  .merge-dataset-row .merge-status {
352
  font-size: 0.75rem;
353
  color: #6c757d;
@@ -409,6 +441,12 @@
409
 
410
  <div id="init-loading">Initializing DuckDB...</div>
411
 
 
 
 
 
 
 
412
  <div class="merge-dataset-row" id="merge-dataset-row" style="display:none">
413
  <input type="text" id="merge-dataset-input" placeholder="HF dataset path, e.g. org/dataset-name or org/dataset-name/file.parquet">
414
  <button class="btn btn-primary btn-sm" id="btn-merge-dataset">Merge Dataset</button>
@@ -426,8 +464,10 @@
426
  <script type="module">
427
  import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/+esm';
428
  import jsyaml from 'https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm';
 
429
 
430
  // ── Globals ─────────────────────────────────────────────────
 
431
  let db = null;
432
  let conn = null;
433
  let panelCounter = 0;
@@ -1781,7 +1821,12 @@
1781
  const id = mergeCounter++;
1782
  const bufferName = `merged_${id}.parquet`;
1783
 
1784
- const response = await fetch(url);
 
 
 
 
 
1785
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
1786
  const buffer = new Uint8Array(await response.arrayBuffer());
1787
  await db.registerFileBuffer(bufferName, buffer);
@@ -1858,6 +1903,69 @@
1858
  }
1859
  }
1860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1861
  // ── Init ────────────────────────────────────────────────────
1862
  const elInitLoading = document.getElementById('init-loading');
1863
  const elAddPanelRow = document.getElementById('add-panel-row');
@@ -1880,6 +1988,9 @@
1880
  elAddPanelRow.style.display = '';
1881
  document.getElementById('merge-dataset-row').style.display = '';
1882
 
 
 
 
1883
  // Create default panel
1884
  await addPanel({ suite: 'eng_base_main', metric: 'acc_norm' });
1885
  } catch (err) {
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>ellamind base-eval</title>
7
  <script src="https://cdn.plot.ly/plotly-2.35.2.min.js" charset="utf-8"></script>
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "@huggingface/hub": "https://cdn.jsdelivr.net/npm/@huggingface/hub@0.21.0/+esm"
12
+ }
13
+ }
14
+ </script>
15
  <style>
16
  * { box-sizing: border-box; margin: 0; padding: 0; }
17
  body {
 
350
  width: 420px;
351
  max-width: 60vw;
352
  }
353
+ .merge-dataset-row input[type="text"]:focus,
354
+ .hf-auth-row input[type="password"]:focus {
355
  outline: none;
356
  border-color: #4361ee;
357
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
358
  }
359
+ .hf-auth-row input[type="password"] {
360
+ padding: 6px 10px;
361
+ border: 1px solid #dee2e6;
362
+ border-radius: 6px;
363
+ font-size: 0.8rem;
364
+ color: #1a1a2e;
365
+ width: 420px;
366
+ max-width: 50vw;
367
+ }
368
+ .hf-auth-row {
369
+ display: flex;
370
+ align-items: center;
371
+ justify-content: center;
372
+ gap: 8px;
373
+ margin-bottom: 8px;
374
+ }
375
+ .hf-auth-row .hf-user {
376
+ font-size: 0.8rem;
377
+ color: #495057;
378
+ }
379
+ .hf-signin-img {
380
+ cursor: pointer;
381
+ height: 28px;
382
+ }
383
  .merge-dataset-row .merge-status {
384
  font-size: 0.75rem;
385
  color: #6c757d;
 
441
 
442
  <div id="init-loading">Initializing DuckDB...</div>
443
 
444
+ <div class="hf-auth-row" id="hf-auth-row" style="display:none">
445
+ <img id="hf-signin-btn" class="hf-signin-img" src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-sm-dark.svg" alt="Sign in with Hugging Face" style="display:none">
446
+ <span id="hf-user" class="hf-user" style="display:none"></span>
447
+ <button class="btn btn-sm" id="hf-signout-btn" style="display:none">Sign out</button>
448
+ <input type="password" id="hf-token-input" placeholder="HF token (for private datasets)" style="display:none">
449
+ </div>
450
  <div class="merge-dataset-row" id="merge-dataset-row" style="display:none">
451
  <input type="text" id="merge-dataset-input" placeholder="HF dataset path, e.g. org/dataset-name or org/dataset-name/file.parquet">
452
  <button class="btn btn-primary btn-sm" id="btn-merge-dataset">Merge Dataset</button>
 
464
  <script type="module">
465
  import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/+esm';
466
  import jsyaml from 'https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm';
467
+ import { oauthLoginUrl, oauthHandleRedirectIfPresent } from '@huggingface/hub';
468
 
469
  // ── Globals ─────────────────────────────────────────────────
470
+ let hfAccessToken = null; // set by OAuth or manual input
471
  let db = null;
472
  let conn = null;
473
  let panelCounter = 0;
 
1821
  const id = mergeCounter++;
1822
  const bufferName = `merged_${id}.parquet`;
1823
 
1824
+ const fetchOpts = {};
1825
+ const token = hfAccessToken || document.getElementById('hf-token-input').value.trim();
1826
+ if (token) {
1827
+ fetchOpts.headers = { 'Authorization': `Bearer ${token}` };
1828
+ }
1829
+ const response = await fetch(url, fetchOpts);
1830
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
1831
  const buffer = new Uint8Array(await response.arrayBuffer());
1832
  await db.registerFileBuffer(bufferName, buffer);
 
1903
  }
1904
  }
1905
 
1906
+ // ── HF Auth ───────────────────────────────────────────────
1907
+ function updateAuthUI(oauthResult) {
1908
+ const authRow = document.getElementById('hf-auth-row');
1909
+ const signinBtn = document.getElementById('hf-signin-btn');
1910
+ const signoutBtn = document.getElementById('hf-signout-btn');
1911
+ const userEl = document.getElementById('hf-user');
1912
+ const tokenInput = document.getElementById('hf-token-input');
1913
+
1914
+ authRow.style.display = '';
1915
+
1916
+ if (!window.huggingface?.variables?.OAUTH_CLIENT_ID) {
1917
+ // Not on HF Spaces β€” hide auth entirely
1918
+ authRow.style.display = 'none';
1919
+ return;
1920
+ }
1921
+
1922
+ authRow.style.display = '';
1923
+ if (oauthResult) {
1924
+ signinBtn.style.display = 'none';
1925
+ tokenInput.style.display = 'none';
1926
+ userEl.textContent = `Signed in as ${oauthResult.userInfo?.name || oauthResult.userInfo?.preferred_username || 'HF user'}`;
1927
+ userEl.style.display = '';
1928
+ signoutBtn.style.display = '';
1929
+ } else {
1930
+ signinBtn.style.display = '';
1931
+ tokenInput.style.display = 'none';
1932
+ userEl.style.display = 'none';
1933
+ signoutBtn.style.display = 'none';
1934
+ }
1935
+ }
1936
+
1937
+ async function initHfAuth() {
1938
+ // Try restoring from localStorage
1939
+ let oauthResult = null;
1940
+ const stored = localStorage.getItem('hf_oauth');
1941
+ if (stored) {
1942
+ try { oauthResult = JSON.parse(stored); } catch { oauthResult = null; }
1943
+ }
1944
+
1945
+ // Handle OAuth redirect (takes priority over stored)
1946
+ oauthResult = (await oauthHandleRedirectIfPresent()) || oauthResult;
1947
+
1948
+ if (oauthResult?.accessToken) {
1949
+ hfAccessToken = oauthResult.accessToken;
1950
+ localStorage.setItem('hf_oauth', JSON.stringify(oauthResult));
1951
+ }
1952
+
1953
+ updateAuthUI(oauthResult);
1954
+
1955
+ // Sign in
1956
+ document.getElementById('hf-signin-btn').addEventListener('click', async () => {
1957
+ const scopes = window.huggingface?.variables?.OAUTH_SCOPES || 'openid profile read-repos';
1958
+ window.location.href = (await oauthLoginUrl({ scopes })) + '&prompt=consent';
1959
+ });
1960
+
1961
+ // Sign out
1962
+ document.getElementById('hf-signout-btn').addEventListener('click', () => {
1963
+ localStorage.removeItem('hf_oauth');
1964
+ hfAccessToken = null;
1965
+ updateAuthUI(null);
1966
+ });
1967
+ }
1968
+
1969
  // ── Init ────────────────────────────────────────────────────
1970
  const elInitLoading = document.getElementById('init-loading');
1971
  const elAddPanelRow = document.getElementById('add-panel-row');
 
1988
  elAddPanelRow.style.display = '';
1989
  document.getElementById('merge-dataset-row').style.display = '';
1990
 
1991
+ // ── HF Auth setup ──
1992
+ await initHfAuth();
1993
+
1994
  // Create default panel
1995
  await addPanel({ suite: 'eng_base_main', metric: 'acc_norm' });
1996
  } catch (err) {