Mike0021 commited on
Commit
b9d7d52
·
verified ·
1 Parent(s): d75f001

Include hosted commit in benchmark exports

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.js +29 -0
README.md CHANGED
@@ -18,7 +18,7 @@ Static browser demo for client-side voice interaction:
18
 
19
  Open the Space, click **Load models**, then **Start mic**. The first load downloads model assets into the browser cache; after that, inference runs in the tab with no server inference.
20
 
21
- After benchmark or real-mic runs, use **Download JSON** to save the `{ summary, results }` evidence file locally.
22
 
23
  Known testing notes:
24
 
 
18
 
19
  Open the Space, click **Load models**, then **Start mic**. The first load downloads model assets into the browser cache; after that, inference runs in the tab with no server inference.
20
 
21
+ After benchmark or real-mic runs, use **Download JSON** to save the evidence file locally. The export includes the hosted Space commit when the static host exposes it.
22
 
23
  Known testing notes:
24
 
app.js CHANGED
@@ -162,6 +162,13 @@ const state = {
162
  ttsVoiceRequests: new Map(),
163
  automationSynthesisRequestId: 0,
164
  automationSynthesisRequests: new Map(),
 
 
 
 
 
 
 
165
  activeTurnId: 0,
166
  modelLoadStartedAt: null,
167
  loadedStack: null,
@@ -390,6 +397,24 @@ function logEvent(message) {
390
  }
391
  }
392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
  function setLoadButton(mode) {
394
  const options = {
395
  load: { icon: "↓", label: "Load models", disabled: false },
@@ -1322,6 +1347,7 @@ function editDistance(reference, hypothesis) {
1322
  function runtimeEnvironment() {
1323
  return {
1324
  page: location.href,
 
1325
  secureContext: window.isSecureContext,
1326
  userAgent: navigator.userAgent,
1327
  platform: navigator.platform || "",
@@ -1634,6 +1660,8 @@ function exportBenchmarkSummary() {
1634
 
1635
  function benchmarkExportPayload() {
1636
  return {
 
 
1637
  summary: exportBenchmarkSummary(),
1638
  results: [...state.benchmarkResults],
1639
  };
@@ -2596,6 +2624,7 @@ updateTtsStepsLabel();
2596
  updateVadSilenceLabel();
2597
  updateMicValidationStatus();
2598
  installAutomationApi();
 
2599
  initRuntimeSupport();
2600
 
2601
  async function initRuntimeSupport() {
 
162
  ttsVoiceRequests: new Map(),
163
  automationSynthesisRequestId: 0,
164
  automationSynthesisRequests: new Map(),
165
+ hostMetadata: {
166
+ page: location.href,
167
+ host: location.host,
168
+ hfSpaceCommit: "",
169
+ etag: "",
170
+ fetchedAt: "",
171
+ },
172
  activeTurnId: 0,
173
  modelLoadStartedAt: null,
174
  loadedStack: null,
 
397
  }
398
  }
399
 
400
+ async function refreshHostMetadata() {
401
+ try {
402
+ const response = await fetch(location.href, { method: "HEAD", cache: "no-store" });
403
+ state.hostMetadata = {
404
+ page: location.href,
405
+ host: location.host,
406
+ hfSpaceCommit: response.headers.get("x-repo-commit") ?? "",
407
+ etag: response.headers.get("etag") ?? "",
408
+ fetchedAt: new Date().toISOString(),
409
+ };
410
+ } catch {
411
+ state.hostMetadata = {
412
+ ...state.hostMetadata,
413
+ fetchedAt: new Date().toISOString(),
414
+ };
415
+ }
416
+ }
417
+
418
  function setLoadButton(mode) {
419
  const options = {
420
  load: { icon: "↓", label: "Load models", disabled: false },
 
1347
  function runtimeEnvironment() {
1348
  return {
1349
  page: location.href,
1350
+ hostMetadata: { ...state.hostMetadata },
1351
  secureContext: window.isSecureContext,
1352
  userAgent: navigator.userAgent,
1353
  platform: navigator.platform || "",
 
1660
 
1661
  function benchmarkExportPayload() {
1662
  return {
1663
+ generatedAt: new Date().toISOString(),
1664
+ hostMetadata: { ...state.hostMetadata },
1665
  summary: exportBenchmarkSummary(),
1666
  results: [...state.benchmarkResults],
1667
  };
 
2624
  updateVadSilenceLabel();
2625
  updateMicValidationStatus();
2626
  installAutomationApi();
2627
+ refreshHostMetadata().catch(() => {});
2628
  initRuntimeSupport();
2629
 
2630
  async function initRuntimeSupport() {