Add dev/: training and export scripts, GPAI rule tests, browser tests, workspace map
28e3615 verified Download dev/browser-tests/live.mjs from Devseis/Caveat: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/live.mjs
- Command line
-
hf download hf://spaces/Devseis/Caveat/dev/browser-tests/live.mjs
-
curl -L -o live.mjs https://huggingface.co/spaces/Devseis/Caveat/resolve/main/dev/browser-tests/live.mjs
2.3 kB
| import puppeteer from "puppeteer-core"; | |
| const S = "/Users/umer/Documents/hf/tools/browser-tests/out"; | |
| const b = await puppeteer.launch({ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", headless: true, userDataDir: S + "/prof_live", protocolTimeout: 180000 }); | |
| const p = await b.newPage(); await p.setCacheEnabled(false); | |
| const errs = []; p.on("pageerror", (e) => errs.push(e.message)); | |
| await p.setRequestInterception(true); | |
| p.on("request", (r) => /clarity\.ms/.test(r.url()) ? r.abort() : r.continue()); | |
| await p.emulate({ viewport: { width: 390, height: 844, deviceScaleFactor: 2, isMobile: true, hasTouch: true }, userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1" }); | |
| const t0 = Date.now(); | |
| await p.goto("https://devseis-caveat.static.hf.space/", { waitUntil: "domcontentloaded", timeout: 60000 }); | |
| await p.waitForFunction(() => { const x = document.getElementById("runBtn"); return !x.disabled; }, { timeout: 150000 }); | |
| const loadMsg = await p.evaluate(() => document.getElementById("runHint").textContent); | |
| console.log(`model ready after ${((Date.now() - t0) / 1000).toFixed(1)}s | hint: "${loadMsg}"`); | |
| for (const [ex, name] of [[1, "CV screening"], [2, "Phone order bot"], [4, "Large AI model"]]) { | |
| await p.click(`.chip[data-ex="${ex}"]`); await p.click("#runBtn"); | |
| await p.waitForFunction(() => ["p1", "p2"].every((k) => !document.getElementById(k + "result").hidden || /Couldn/.test(document.getElementById(k + "status").textContent)), { timeout: 60000 }); | |
| await new Promise((r) => setTimeout(r, 1200)); | |
| const r = await p.evaluate(() => ({ p1: document.getElementById("p1pill").textContent, p1why: document.getElementById("p1rationale").textContent.slice(0, 70), | |
| p2: document.getElementById("p2result").hidden ? document.getElementById("p2status").textContent : document.getElementById("p2pill").textContent, | |
| agree: document.getElementById("agree").hidden ? "-" : document.getElementById("agree").textContent })); | |
| console.log(`${name}: trained model → ${r.p1} (${r.p1why}…) | reasoning AI → ${r.p2} | ${r.agree}`); | |
| if (ex === 1) await p.screenshot({ path: S + "/live_phone.png" }); | |
| } | |
| console.log("page errors:", errs.length ? errs.join(" | ") : "none"); await b.close(); | |