quantcheck 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantcheck/__init__.py +3 -0
- quantcheck/auth/__init__.py +6 -0
- quantcheck/auth/base.py +74 -0
- quantcheck/auth/callback.py +73 -0
- quantcheck/auth/fake.py +40 -0
- quantcheck/auth/service.py +49 -0
- quantcheck/auth/store.py +63 -0
- quantcheck/auth/supabase.py +168 -0
- quantcheck/bench.py +38 -0
- quantcheck/candidates.py +138 -0
- quantcheck/cli.py +251 -0
- quantcheck/config.py +63 -0
- quantcheck/executors/__init__.py +0 -0
- quantcheck/hardware.py +52 -0
- quantcheck/limits.py +19 -0
- quantcheck/pipeline.py +172 -0
- quantcheck/prompt.py +67 -0
- quantcheck/recommend.py +131 -0
- quantcheck/report/__init__.py +0 -0
- quantcheck/report/html.py +38 -0
- quantcheck/report/templates/report.html.j2 +272 -0
- quantcheck/report/terminal.py +90 -0
- quantcheck/report/tokens.py +41 -0
- quantcheck/report/view.py +161 -0
- quantcheck/runners/__init__.py +3 -0
- quantcheck/runners/base.py +87 -0
- quantcheck/runners/fake.py +68 -0
- quantcheck/runners/llamacpp_runner.py +185 -0
- quantcheck/runners/mlx_runner.py +153 -0
- quantcheck/runners/toolparse.py +107 -0
- quantcheck/scoring/__init__.py +0 -0
- quantcheck/scoring/checks.py +342 -0
- quantcheck/scoring/fake_judge.py +50 -0
- quantcheck/scoring/judge.py +171 -0
- quantcheck/scoring/language.py +99 -0
- quantcheck/scoring/models.py +92 -0
- quantcheck/scoring/score.py +167 -0
- quantcheck/scoring/stats.py +60 -0
- quantcheck/settings.py +14 -0
- quantcheck/store.py +88 -0
- quantcheck/tests_io.py +169 -0
- quantcheck/ui/__init__.py +1 -0
- quantcheck/ui/app.py +534 -0
- quantcheck/ui/catalog.py +47 -0
- quantcheck/ui/chat.py +211 -0
- quantcheck/ui/compare.py +63 -0
- quantcheck/ui/downloads.py +172 -0
- quantcheck/ui/jobs.py +173 -0
- quantcheck/ui/modeldetail.py +97 -0
- quantcheck/ui/reviews.py +59 -0
- quantcheck/ui/security.py +45 -0
- quantcheck/ui/static/chat.js +312 -0
- quantcheck/ui/static/fonts/JetBrainsMono-latin-b87346.woff2 +0 -0
- quantcheck/ui/static/fonts/JetBrainsMono-latin-ext-9326b4.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-devanagari-3819bb.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-latin-ext-542103.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansDevanagari-latin-f3aaed.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-latin-17e6dc.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-latin-ext-027c12.woff2 +0 -0
- quantcheck/ui/static/fonts/NotoSansTamil-tamil-a57d5e.woff2 +0 -0
- quantcheck/ui/static/fonts/Outfit-latin-ebadd8.woff2 +0 -0
- quantcheck/ui/static/fonts/Outfit-latin-ext-744997.woff2 +0 -0
- quantcheck/ui/static/fonts/README.md +14 -0
- quantcheck/ui/static/fonts.css +228 -0
- quantcheck/ui/static/index.html +24 -0
- quantcheck/ui/static/lab.css +768 -0
- quantcheck/ui/static/lab.js +896 -0
- quantcheck/ui/static/logo.svg +5 -0
- quantcheck/ui/static/review.js +127 -0
- quantcheck/ui/static/setup.js +132 -0
- quantcheck/ui/static/testsets.js +527 -0
- quantcheck/ui/summary.py +104 -0
- quantcheck/ui/system.py +101 -0
- quantcheck/ui/testsets.py +243 -0
- quantcheck-0.0.1.dist-info/METADATA +115 -0
- quantcheck-0.0.1.dist-info/RECORD +79 -0
- quantcheck-0.0.1.dist-info/WHEEL +4 -0
- quantcheck-0.0.1.dist-info/entry_points.txt +2 -0
- quantcheck-0.0.1.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" role="img" aria-label="quantcheck logo">
|
|
2
|
+
<rect width="40" height="40" rx="10" fill="#047857"/>
|
|
3
|
+
<circle cx="19" cy="19" r="9" fill="none" stroke="#fff" stroke-width="3.2"/>
|
|
4
|
+
<path d="M21 22 L25.5 26.5 L34 16" fill="none" stroke="#6EE7B7" stroke-width="3.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* Review changed answers (design: Lab-Review). Uses helpers from lab.js (h, api, shell, mount).
|
|
2
|
+
Verdicts are saved next to the run as reviews.json; the run itself is never changed. */
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const KIND = { check_failed: ["fail", "Check failed"], error: ["fail", "Error"], worse: ["warn", "Judged worse"] };
|
|
6
|
+
const VERDICTS = [["acceptable", "Mark as acceptable", "1"], ["problem", "Confirm regression", "2"], ["unsure", "Not sure", "3"]];
|
|
7
|
+
|
|
8
|
+
async function screenReview(arg) {
|
|
9
|
+
const [runId, ver] = arg.split("/").map(decodeURIComponent);
|
|
10
|
+
const body = h("div", { class: "stack" }, h("p", { class: "muted", text: "Loading…" }));
|
|
11
|
+
const topActions = h("a", { class: "btn", href: `#/report/${encodeURIComponent(runId)}`, text: "Back to report" });
|
|
12
|
+
mount(shell(["Runs", runId, "Review"], body, "#/runs", topActions));
|
|
13
|
+
let data;
|
|
14
|
+
try { data = await api(`/api/runs/${encodeURIComponent(runId)}/changes`); }
|
|
15
|
+
catch (e) { body.replaceChildren(h("div", { class: "notice fail", text: e.message }), h("a", { class: "btn", href: "#/home", text: "Back to Home" })); return; }
|
|
16
|
+
if (!data.scored) {
|
|
17
|
+
body.replaceChildren(h("div", { class: "notice warn", text: "This run was not scored, so there are no changed answers yet. Run `quantcheck rescore " + runId + "` first." }));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// The reference's own failures are reviewable too.
|
|
21
|
+
const lists = { ...data.changes };
|
|
22
|
+
if (data.reference_label && data.reference_failures.length) lists[data.reference_label] = data.reference_failures;
|
|
23
|
+
const labels = data.versions.filter((v) => v.status === "ok" && (v.is_reference ? lists[v.label] : true)).map((v) => v.label);
|
|
24
|
+
const st = { version: labels.includes(ver) ? ver : (labels.find((l) => l !== data.reference_label && (lists[l] || []).length) || labels.find((l) => (lists[l] || []).length) || labels[0]), filter: "all", sel: 0, reviews: data.reviews || {} };
|
|
25
|
+
if (!st.version) { body.replaceChildren(h("div", { class: "notice ok", text: "No versions to review." })); return; }
|
|
26
|
+
|
|
27
|
+
const items = () => lists[st.version] || [];
|
|
28
|
+
const tone = (c) => (c.kind === "worse" ? "warn" : "fail");
|
|
29
|
+
const visible = () => items().filter((c) => st.filter === "all" || (st.filter === "fail" ? tone(c) === "fail" : tone(c) === "warn"));
|
|
30
|
+
const verdictOf = (c) => ((st.reviews[st.version] || {})[c.case_id] || {}).verdict || "";
|
|
31
|
+
const noteOf = (c) => ((st.reviews[st.version] || {})[c.case_id] || {}).note || "";
|
|
32
|
+
const titleBox = h("div", { class: "rv-title" });
|
|
33
|
+
const listBox = h("nav", { class: "card rv-list", "aria-label": "Changed answers" });
|
|
34
|
+
const detail = h("section", { class: "card rv-detail", "aria-live": "polite" });
|
|
35
|
+
const saveNote = h("span", { class: "mu rv-save" });
|
|
36
|
+
const refLabel = data.reference_label || "reference";
|
|
37
|
+
|
|
38
|
+
// "If you accept": a what-if only. Each answer you marked acceptable is scored as the reference's answer to
|
|
39
|
+
// the same prompt. The saved score and the recommendation are not changed (the run stays reproducible).
|
|
40
|
+
const whatIf = h("p", { class: "rv-whatif", "aria-live": "polite" });
|
|
41
|
+
function drawWhatIf() {
|
|
42
|
+
const ver = data.versions.find((x) => x.label === st.version), rq = data.reference_quality, mine = st.reviews[st.version] || {};
|
|
43
|
+
const accepted = items().filter((c) => (mine[c.case_id] || {}).verdict === "acceptable" && c.quality !== null && c.reference_quality !== null);
|
|
44
|
+
whatIf.hidden = !accepted.length || !ver || ver.is_reference || !ver.n_scored || !rq || ver.quality === null;
|
|
45
|
+
if (whatIf.hidden) return;
|
|
46
|
+
const gain = accepted.reduce((a, c) => a + (c.reference_quality - c.quality), 0) / ver.n_scored;
|
|
47
|
+
const now = ver.quality, after = Math.min(1, now + gain), pct = (x) => `${(x * 100).toFixed(1)}%`;
|
|
48
|
+
whatIf.replaceChildren(h("b", { text: "If you accept " }), `the ${accepted.length} answer${accepted.length === 1 ? "" : "s"} you marked acceptable, ${st.version} would score `, h("b", { class: "mono", text: `${pct(now)} → ${pct(after)}` }),
|
|
49
|
+
`, which is ${pct(after / rq)} of ${refLabel}. `, h("span", { class: "mu", text: "A what-if only: the saved scores and the recommendation do not change." }));
|
|
50
|
+
}
|
|
51
|
+
async function setReview(c, verdict, note) {
|
|
52
|
+
const rev = (st.reviews[st.version] = st.reviews[st.version] || {});
|
|
53
|
+
const prev = rev[c.case_id];
|
|
54
|
+
if (!verdict && !note) delete rev[c.case_id]; else rev[c.case_id] = { verdict: verdict || "", note: note || "" };
|
|
55
|
+
drawList(); drawWhatIf();
|
|
56
|
+
try {
|
|
57
|
+
await api(`/api/runs/${encodeURIComponent(runId)}/reviews`, { method: "PUT", body: { version: st.version, case_id: c.case_id, verdict: verdict || null, note: note || "" } });
|
|
58
|
+
saveNote.textContent = "Saved";
|
|
59
|
+
} catch (e) {
|
|
60
|
+
if (prev) rev[c.case_id] = prev; else delete rev[c.case_id];
|
|
61
|
+
saveNote.textContent = `Not saved: ${e.message}`; drawList(); drawDetail(); drawWhatIf();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function drawTitle() {
|
|
66
|
+
const all = items(), total = data.changes_total[st.version] ?? all.length;
|
|
67
|
+
const n = (f) => items().filter((c) => (f === "fail" ? tone(c) === "fail" : tone(c) === "warn")).length;
|
|
68
|
+
const chip = (key, text) => h("button", { type: "button", class: `chip nodot rv-chip ${st.filter === key ? "on" : ""}`, "aria-pressed": String(st.filter === key), onclick: () => { st.filter = key; st.sel = 0; drawAll(); } }, text);
|
|
69
|
+
titleBox.replaceChildren(
|
|
70
|
+
h("div", { class: "rv-t" }, h("h2", { class: "nt-h1", text: `Answers that changed · ${st.version}` }),
|
|
71
|
+
h("p", { class: "mu nt-sub", text: `${(data.model || "").split("/").pop()} · compared with the ${refLabel} reference · ${total} of ${data.n_prompts ?? "?"} prompts flagged` })),
|
|
72
|
+
h("div", { class: "rv-tools" },
|
|
73
|
+
labels.length > 1 ? h("select", { "aria-label": "Version", onchange: (e) => { st.version = e.target.value; st.filter = "all"; st.sel = 0; drawAll(); } }, labels.map((l) => h("option", { value: l, selected: l === st.version, text: `${l}${l === data.reference_label ? " (reference)" : ""} · ${(lists[l] || []).length}` }))) : null,
|
|
74
|
+
chip("all", `All ${all.length}`), chip("fail", `Failed ${n("fail")}`), chip("warn", `Changed ${n("warn")}`)));
|
|
75
|
+
}
|
|
76
|
+
function drawList() {
|
|
77
|
+
const v = visible();
|
|
78
|
+
st.sel = Math.min(st.sel, Math.max(0, v.length - 1));
|
|
79
|
+
listBox.replaceChildren(...v.map((c, k) => {
|
|
80
|
+
const mark = verdictOf(c);
|
|
81
|
+
return h("button", { type: "button", class: `rv-item ${k === st.sel ? "on" : ""}`, onclick: () => { st.sel = k; drawList(); drawDetail(); } },
|
|
82
|
+
h("span", { class: "mono rv-id", text: c.case_id }),
|
|
83
|
+
h("span", { class: "rv-r" }, mark ? h("span", { class: "rv-done", title: "Reviewed", text: "✓" }) : null, h("span", { class: `chip nodot rv-reason ${tone(c)}`, text: (KIND[c.kind] || ["", c.kind])[1] })));
|
|
84
|
+
}), ...(v.length ? [] : [h("span", { class: "mu rv-none", text: items().length ? "Nothing matches this filter." : "Nothing flagged." })]));
|
|
85
|
+
}
|
|
86
|
+
function drawDetail() {
|
|
87
|
+
const v = visible(), c = v[st.sel];
|
|
88
|
+
if (!c) {
|
|
89
|
+
detail.replaceChildren(items().length ? h("div", { class: "rv-empty" }, h("p", { class: "muted", text: "Nothing matches this filter." }))
|
|
90
|
+
: emptyCard(["M5 12l5 5L20 7"], "No answers changed", `Every ${st.version} answer matched the reference closely enough. Nothing to review.`, [h("a", { class: "btn", href: `#/report/${encodeURIComponent(runId)}`, text: "Back to report" })]));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const [, kindLabel] = KIND[c.kind] || ["", c.kind];
|
|
94
|
+
const note = h("input", { type: "text", value: noteOf(c), placeholder: "Note (optional)", "aria-label": `Note for ${c.case_id}`, autocomplete: "off" });
|
|
95
|
+
let t = null;
|
|
96
|
+
note.addEventListener("input", () => { clearTimeout(t); t = setTimeout(() => setReview(c, verdictOf(c), note.value), 500); });
|
|
97
|
+
const btns = VERDICTS.map(([vv, label, key]) => h("button", { type: "button", class: "btn rv-btn", "data-v": vv, "aria-pressed": String(verdictOf(c) === vv), "aria-keyshortcuts": key,
|
|
98
|
+
onclick: (e) => { const on = verdictOf(c) !== vv; setReview(c, on ? vv : "", note.value); for (const b of e.currentTarget.parentElement.children) b.setAttribute("aria-pressed", String(on && b.dataset.v === vv)); } }, label));
|
|
99
|
+
const go = (d) => { st.sel = Math.max(0, Math.min(v.length - 1, st.sel + d)); drawList(); drawDetail(); };
|
|
100
|
+
detail.replaceChildren(
|
|
101
|
+
h("div", { class: "rv-dh" }, h("span", { class: "mono mu rv-sm", text: `${c.case_id}${c.tags.length ? " · " + c.tags.join(", ") : ""}` }), h("span", { class: `chip nodot rv-reason ${tone(c)}`, text: kindLabel }),
|
|
102
|
+
h("span", { class: "rv-q", text: c.prompt })),
|
|
103
|
+
c.documents.length ? h("details", { class: "rv-docs" }, h("summary", { text: `Documents sent (${c.documents.length})` }), ...c.documents.map((d, i) => h("div", { class: "rv-doc", text: `[${i + 1}] ${d}` }))) : null,
|
|
104
|
+
h("div", { class: "rv-cols" },
|
|
105
|
+
h("div", { class: "rv-col" }, h("span", { class: "lbl", text: `${c.reference_name || refLabel}` }), h("p", { text: c.reference_text || "(none)" })),
|
|
106
|
+
h("div", { class: `rv-col bad ${tone(c)}` }, h("span", { class: "lbl", text: st.version }), h("p", { text: c.answer_text || "(empty)" }))),
|
|
107
|
+
h("div", { class: "rv-judge" }, h("span", {}, c.judge_reason ? h("b", { text: "Judge" }) : h("b", { text: kindLabel }), ` · ${c.judge_reason || c.why || ""}`),
|
|
108
|
+
h("div", { class: "rv-verdicts", role: "group", "aria-label": "Your verdict" }, btns)),
|
|
109
|
+
h("div", { class: "rv-note" }, note),
|
|
110
|
+
h("div", { class: "rv-nav" }, h("button", { type: "button", class: "btn rv-n", "aria-label": "Previous", onclick: () => go(-1), disabled: st.sel === 0 }, svgEl(["M15 6l-6 6 6 6"], "ico")),
|
|
111
|
+
h("button", { type: "button", class: "btn rv-n", "aria-label": "Next", onclick: () => go(1), disabled: st.sel >= v.length - 1 }, svgEl(["M9 6l6 6-6 6"], "ico")),
|
|
112
|
+
h("span", { class: "mono mu rv-sm", text: `${st.sel + 1} of ${v.length}` }), saveNote,
|
|
113
|
+
h("span", { class: "mu rv-sm rv-r2", text: "Your decisions are saved beside this run. They do not change the recommendation." })));
|
|
114
|
+
}
|
|
115
|
+
function drawAll() { drawTitle(); drawList(); drawDetail(); drawWhatIf(); history.replaceState(null, "", `#/review/${encodeURIComponent(runId)}/${encodeURIComponent(st.version)}`); }
|
|
116
|
+
|
|
117
|
+
body.replaceChildren(titleBox, whatIf, h("div", { class: "rv-grid" }, listBox, detail),
|
|
118
|
+
h("p", { class: "hint", text: "Keys: 1 acceptable, 2 confirm regression, 3 not sure, j next, k previous." }));
|
|
119
|
+
drawAll();
|
|
120
|
+
window.onkeydown = (e) => {
|
|
121
|
+
if (!detail.isConnected) { window.onkeydown = null; return; }
|
|
122
|
+
if (e.target.matches("input,textarea,select") || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
123
|
+
if (e.key === "j") detail.querySelector(".rv-n[aria-label=Next]")?.click();
|
|
124
|
+
else if (e.key === "k") detail.querySelector(".rv-n[aria-label=Previous]")?.click();
|
|
125
|
+
else if (["1", "2", "3"].includes(e.key)) detail.querySelectorAll(".rv-btn")[Number(e.key) - 1]?.click();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* First-run Setup (design: Lab-Setup): check this Mac, pick a first model, download it.
|
|
2
|
+
Everything shown comes from this Mac (hardware, runtimes, disk) or from Hugging Face when the
|
|
3
|
+
user clicks Download (exact sizes). Before that, sizes are marked "~" estimates. */
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const SETUP_OVERHEAD = 1.1; // file size is about params x bits / 8, plus ~10%
|
|
7
|
+
const SETUP_HEADROOM_GB = 2;
|
|
8
|
+
const setupUi = { step: 1, pick: null };
|
|
9
|
+
|
|
10
|
+
const gbText = (b) => `${(b / 1e9).toFixed(1)} GB`;
|
|
11
|
+
const minsText = (s) => (s < 90 ? "under a minute" : `about ${Math.round(s / 60)} min`);
|
|
12
|
+
|
|
13
|
+
async function screenSetup() {
|
|
14
|
+
stopPolling();
|
|
15
|
+
const box = h("div", { class: "fs-card" }, h("p", { class: "muted", text: "Checking this Mac…" }));
|
|
16
|
+
mount(h("div", { class: "fs" }, box));
|
|
17
|
+
let sys, models, dl;
|
|
18
|
+
try { [sys, models, dl] = await Promise.all([api("/api/system"), api("/api/models/setup"), api("/api/downloads")]); }
|
|
19
|
+
catch (e) { box.replaceChildren(alertCard("fail", "Setup could not start", e.message, [h("a", { class: "btn", href: "#/home", text: "Go to Home" })])); return; }
|
|
20
|
+
if (dl.items.length) setupUi.step = 3;
|
|
21
|
+
const ram = sys.hardware.ram_gb, free = sys.hardware.free_disk_gb, budget = ram - SETUP_HEADROOM_GB;
|
|
22
|
+
const estGb = (m, bits) => m.params_b * (bits / 8) * SETUP_OVERHEAD;
|
|
23
|
+
const fitBits = (m) => m.bits.filter((b) => estGb(m, b) <= budget);
|
|
24
|
+
const skip = () => { store.set("qc-setup-done", "1"); location.hash = "#/home"; };
|
|
25
|
+
|
|
26
|
+
const steps = () => h("div", { class: "fs-steps" }, ...[["Check your Mac", 1], ["Pick a first model", 2], ["Download", 3]].flatMap(([label, n], i) =>
|
|
27
|
+
[i ? h("span", { class: "fs-line" }) : null,
|
|
28
|
+
h("span", { class: `fs-stp ${setupUi.step >= n ? "on" : ""} ${setupUi.step === n ? "cur" : ""}` }, h("span", { class: "mono fs-dot" }, setupUi.step > n ? svgEl(["M5 12l5 5L20 7"], "ico") : String(n)), h("span", { class: "fs-lbl", text: label }))].filter(Boolean)));
|
|
29
|
+
const head = () => h("div", { class: "fs-brand" }, logoMark(), h("span", { class: "word", text: "quantcheck" }), h("span", { class: "chip plain lab-badge", text: "Lab" }), h("span", { class: "mu fs-time", text: "Setup · about 2 minutes" }));
|
|
30
|
+
const frame = (...kids) => box.replaceChildren(head(), steps(), ...kids.filter(Boolean));
|
|
31
|
+
|
|
32
|
+
// ---- 1. check the Mac
|
|
33
|
+
function stepCheck() {
|
|
34
|
+
const apple = /apple|m\d/i.test(sys.hardware.chip) && sys.hardware.machine === "arm64";
|
|
35
|
+
const rt = sys.runtimes, ready = [rt.mlx ? "MLX" : null, rt.llamacpp ? "llama.cpp" : null].filter(Boolean);
|
|
36
|
+
const big = [8, 6, 4].find((b) => 8 * (b / 8) * SETUP_OVERHEAD <= budget);
|
|
37
|
+
const row = (ok, title, sub, value) => h("div", { class: "fs-row" }, h("span", { class: `fs-ic ${ok ? "ok" : "warn"}` }, ok ? svgEl(["M5 12l5 5L20 7"], "ico") : h("b", { text: "!" })),
|
|
38
|
+
h("span", { class: "fs-rt" }, h("b", { text: title }), sub ? h("small", { class: "mu", text: sub }) : null), h("span", { class: "mono fs-rv", text: value }));
|
|
39
|
+
const allOk = apple && ready.length > 0;
|
|
40
|
+
frame(h("h1", { text: allOk ? "Your Mac is ready" : "Almost ready" }),
|
|
41
|
+
h("p", { class: "mu", text: allOk ? "We checked what this Mac can run. Nothing was sent anywhere." : "We checked what this Mac can run. Nothing was sent anywhere. A few things need attention." }),
|
|
42
|
+
h("div", { class: "fs-grid" },
|
|
43
|
+
row(apple, "Chip", apple ? null : "QuantCheck needs Apple Silicon (M1 to M4)", sys.hardware.chip),
|
|
44
|
+
row(Boolean(big), "Memory", big ? `Fits 8B models up to ${big}-bit` : "Too small for 8B models. Try the 4B models.", `${ram} GB`),
|
|
45
|
+
row(free >= 10, "Free disk", free >= 10 ? `Room for about ${Math.floor(free / estGb({ params_b: 8 }, 8))} 8-bit 8B model${Math.floor(free / estGb({ params_b: 8 }, 8)) === 1 ? "" : "s"}` : "Low. Free some space before downloading.", `${free} GB`),
|
|
46
|
+
row(ready.length > 0, "Runtimes", ready.length ? null : "Install one: pip install \"quantcheck[mlx]\"", ready.length ? ready.join(" · ") : "None found"),
|
|
47
|
+
row(true, "Ollama", sys.ollama_models.length ? "Found on this Mac. Testing Ollama models comes later." : "Optional", sys.ollama_models.length ? `${sys.ollama_models.length} model${sys.ollama_models.length === 1 ? "" : "s"} found` : "None found"),
|
|
48
|
+
row(true, "Python", null, sys.python)),
|
|
49
|
+
h("div", { class: "fs-foot end" }, h("button", { type: "button", class: "btn primary fs-big", onclick: () => { setupUi.step = 2; stepPick(); } }, "Continue ", svgEl(["M5 12h14M13 6l6 6-6 6"], "ico"))));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---- 2. pick a first model
|
|
53
|
+
function stepPick() {
|
|
54
|
+
setupUi.step = 2;
|
|
55
|
+
const usable = models.filter((m) => fitBits(m).length >= 2);
|
|
56
|
+
if (!setupUi.pick || !usable.some((m) => m.key === setupUi.pick)) setupUi.pick = (usable[0] || {}).key || null;
|
|
57
|
+
const pick = models.find((m) => m.key === setupUi.pick);
|
|
58
|
+
const cards = models.map((m) => {
|
|
59
|
+
const bits = fitBits(m), fits = bits.length >= 2, on = m.key === setupUi.pick;
|
|
60
|
+
return h("button", { type: "button", class: `fs-model ${on ? "on" : ""}`, disabled: !fits, "aria-pressed": String(on), onclick: () => { setupUi.pick = m.key; stepPick(); } },
|
|
61
|
+
h("span", { class: "fs-mtop" }, h("span", { class: "chip ok", text: m.tag }), h("span", { class: "fs-radio" })),
|
|
62
|
+
h("b", { class: "fs-mname", text: m.name }), h("span", { class: "mu", text: m.why }),
|
|
63
|
+
h("span", { class: "fs-vers", text: fits ? `${bits.length} versions · ${bits.map((b) => `${b}-bit`).join(", ")}` : `Too big for ${ram} GB` }),
|
|
64
|
+
h("span", { class: "mono fs-size", text: fits ? `~${bits.reduce((a, b) => a + estGb(m, b), 0).toFixed(1)} GB download` : "" }));
|
|
65
|
+
});
|
|
66
|
+
const total = pick ? fitBits(pick).reduce((a, b) => a + estGb(pick, b), 0) : 0;
|
|
67
|
+
const tight = pick && total + 1 > free;
|
|
68
|
+
frame(h("h1", { text: "Pick a first model" }),
|
|
69
|
+
h("p", { class: "mu", text: `Each one downloads its 8, 6 and 4-bit versions so you can compare them. They fit your ${ram} GB. You can add more later.` }),
|
|
70
|
+
h("div", { class: "fs-models" }, cards),
|
|
71
|
+
tight ? alertCard("warn", "Tight on disk space", `This download is about ${total.toFixed(1)} GB and this Mac has ${free} GB free. Free some space first, or choose a smaller model.`, []) : null,
|
|
72
|
+
h("div", { class: "fs-foot" }, h("button", { type: "button", class: "btn", onclick: stepCheck, text: "Back" }),
|
|
73
|
+
h("span", { class: "row" }, h("button", { type: "button", class: "fs-skip", onclick: skip, text: "Skip for now" }),
|
|
74
|
+
h("button", { type: "button", class: "btn primary fs-big", disabled: !pick, onclick: () => startDownload(pick) }, svgEl(["M12 3v12M7 10l5 5 5-5M5 21h14"], "ico"), pick ? `Download ${pick.name}` : "Download"))));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function startDownload(m) {
|
|
78
|
+
const bits = fitBits(m);
|
|
79
|
+
try { dl = await api("/api/downloads", { method: "POST", body: { models: bits.map((b) => ({ repo: `${m.repo_base}-${b}bit`, label: `${b}-bit` })) } }); }
|
|
80
|
+
catch (e) { box.prepend(alertCard("fail", "Could not start the download", e.message, [])); return; }
|
|
81
|
+
store.set("qc-setup-done", "1"); setupUi.step = 3; stepDownload(); poll();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ---- 3. download
|
|
85
|
+
function stepDownload() {
|
|
86
|
+
setupUi.step = 3;
|
|
87
|
+
const m = models.find((x) => dl.items.length && dl.items[0].repo.startsWith(x.repo_base)) || models[0];
|
|
88
|
+
const done = dl.items.filter((i) => i.state === "done").length, bad = dl.items.filter((i) => i.state === "error");
|
|
89
|
+
const finished = !dl.running && dl.items.length > 0;
|
|
90
|
+
const known = dl.total_bytes !== null && dl.total_bytes !== undefined;
|
|
91
|
+
const overall = known ? (dl.done_bytes / dl.total_bytes) : 0;
|
|
92
|
+
const rows = dl.items.map((it) => {
|
|
93
|
+
const pct = it.percent === null || it.percent === undefined ? 0 : it.percent;
|
|
94
|
+
const state = it.state;
|
|
95
|
+
const icon = state === "done" ? h("span", { class: "fs-ic ok solid" }, svgEl(["M5 12l5 5L20 7"], "ico"))
|
|
96
|
+
: state === "downloading" ? ring(pct)
|
|
97
|
+
: state === "error" ? h("span", { class: "fs-ic fail" }, h("b", { text: "✕" })) : h("span", { class: "fs-ic dash" });
|
|
98
|
+
const note = state === "done" ? "Downloaded" : state === "error" ? `Skipped: ${it.error}` : state === "downloading" ? `${gbText(it.done_bytes)} of ${it.total_bytes ? gbText(it.total_bytes) : "…"}` : "Starts after the one above";
|
|
99
|
+
return h("div", { class: "fs-dl" }, icon, h("div", { class: "fs-dlb" },
|
|
100
|
+
h("div", { class: "fs-dlh" }, h("span", {}, h("b", { text: it.label }), it.total_bytes ? h("small", { class: "mu", text: ` ${gbText(it.total_bytes)}` }) : null),
|
|
101
|
+
state === "waiting" ? h("span", { class: "mono fs-wait", text: "waiting" }) : state === "error" ? h("span", { class: "mono fs-bad", text: "failed" }) : h("span", { class: "mono fs-pct", text: `${pct}%` })),
|
|
102
|
+
h("div", { class: `fs-bar ${state}` }, h("i", { class: state === "downloading" ? "active" : "", style: `width:${state === "waiting" || state === "error" ? 0 : pct}%` })),
|
|
103
|
+
h("small", { class: `mu ${state === "error" ? "fs-bad" : ""}`, text: note })));
|
|
104
|
+
});
|
|
105
|
+
const left = dl.seconds_left ? `${minsText(dl.seconds_left)} left` : "";
|
|
106
|
+
const speed = dl.bytes_per_s ? `${(dl.bytes_per_s / 1e6).toFixed(0)} MB/s` : "";
|
|
107
|
+
frame(h("h1", { text: finished ? (bad.length ? `${m.name} downloaded, with problems` : `${m.name} is ready`) : `Downloading ${m.name}` }),
|
|
108
|
+
h("p", { class: "mu", text: finished ? `${done} of ${dl.items.length} versions downloaded and checked.` : "Keep the lab running while this downloads. If it is interrupted, start it again and it resumes where it stopped." }),
|
|
109
|
+
h("div", { class: "fs-prog" },
|
|
110
|
+
h("div", { class: "fs-ph" }, h("b", { text: known ? `${gbText(dl.done_bytes)} of ${gbText(dl.total_bytes)}` : "Checking sizes on Hugging Face…" }), h("span", { class: "mu", text: [left, speed].filter(Boolean).join(" · ") })),
|
|
111
|
+
h("div", { class: "fs-segs", role: "progressbar", "aria-label": "Download progress", "aria-valuemin": "0", "aria-valuemax": "100", "aria-valuenow": String(Math.round(overall * 100)) },
|
|
112
|
+
dl.items.map((it) => h("span", { class: it.state === "done" ? "done" : it.state === "downloading" ? "active" : it.state === "error" ? "fail" : "" }))),
|
|
113
|
+
h("hr", { class: "fs-hr" }), ...rows),
|
|
114
|
+
finished && !bad.length ? h("div", { class: "fs-next" }, h("span", {}, h("b", { text: "Next:" }), " add your prompts or start from the example test set, then run your first test.")) :
|
|
115
|
+
h("div", { class: "fs-next" }, h("span", {}, h("b", { text: "While you wait:" }), " add your prompts, or start from a ready test set. Your first test can begin as soon as 2 versions are down."), h("a", { class: "btn", href: "#/sets", text: "Add prompts" })),
|
|
116
|
+
h("div", { class: "fs-foot" }, h("button", { type: "button", class: "btn", disabled: dl.running, onclick: () => { dl = { items: [], running: false }; stepPick(); }, text: finished ? "Pick another" : "Back" }),
|
|
117
|
+
h("a", { class: "btn primary fs-big", href: finished && done >= 2 ? "#/new" : "#/home", onclick: () => store.set("qc-setup-done", "1") }, finished && done >= 2 ? "Run your first test " : "Open the lab ", svgEl(["M5 12h14M13 6l6 6-6 6"], "ico"))));
|
|
118
|
+
}
|
|
119
|
+
function ring(pct) {
|
|
120
|
+
const s = document.createElementNS(SVG, "svg"); s.setAttribute("viewBox", "0 0 26 26"); s.setAttribute("class", "fs-ring"); s.setAttribute("aria-hidden", "true");
|
|
121
|
+
const mk = (cls, off) => { const c = document.createElementNS(SVG, "circle"); for (const [k, v] of Object.entries({ cx: 13, cy: 13, r: 10, fill: "none", "stroke-width": 3, class: cls })) c.setAttribute(k, v); if (off !== undefined) { c.setAttribute("stroke-dasharray", "62.8"); c.setAttribute("stroke-dashoffset", String(62.8 * (1 - pct / 100))); c.setAttribute("stroke-linecap", "round"); c.setAttribute("transform", "rotate(-90 13 13)"); } s.append(c); };
|
|
122
|
+
mk("fs-rt0"); mk("fs-rt1", 1); return s;
|
|
123
|
+
}
|
|
124
|
+
async function poll() {
|
|
125
|
+
if (!location.hash.startsWith("#/setup")) return;
|
|
126
|
+
try { dl = await api("/api/downloads"); } catch (e) { return; }
|
|
127
|
+
stepDownload();
|
|
128
|
+
if (dl.running) pollTimer = setTimeout(poll, 700);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (setupUi.step === 3 && dl.items.length) { stepDownload(); if (dl.running) poll(); } else if (setupUi.step === 2) stepPick(); else stepCheck();
|
|
132
|
+
}
|