vectorbench 3.0.2 → 3.0.3
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.
- package/bin/vectorbench.mjs +1 -1
- package/package.json +2 -1
- package/scripts/harness.mjs +35 -23
- package/scripts/partner.mjs +33 -2
- package/scripts/sheet.mjs +75 -0
package/bin/vectorbench.mjs
CHANGED
|
@@ -16,7 +16,7 @@ const { version } = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'))
|
|
|
16
16
|
const HELP = `vectorbench ${version}: draw VectorBench's prompts with your own model (https://vectorbench.ai)
|
|
17
17
|
|
|
18
18
|
vectorbench draw --model <id> draw every prompt with one model and zip the drawings to send
|
|
19
|
-
(--prompt <id> for one first; \`vectorbench draw\`
|
|
19
|
+
(--prompt <id> for one first; \`vectorbench draw --help\` lists the options)
|
|
20
20
|
vectorbench doctor check this machine has what a drawing run needs
|
|
21
21
|
vectorbench prompts list the prompts
|
|
22
22
|
vectorbench dev run the site locally with made-up data (in a clone of the repository)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vectorbench",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Draw VectorBench's SVG prompts with your own model, in the same sandbox as the benchmark at vectorbench.ai",
|
|
5
5
|
"homepage": "https://vectorbench.ai",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"scripts/harness.mjs",
|
|
30
30
|
"scripts/doctor.mjs",
|
|
31
31
|
"scripts/zip.mjs",
|
|
32
|
+
"scripts/sheet.mjs",
|
|
32
33
|
"harness/*.mjs",
|
|
33
34
|
"harness/adapters/",
|
|
34
35
|
"harness/box/",
|
package/scripts/harness.mjs
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
// model could finish a run through it, and six of 17 drawings came back over
|
|
48
48
|
// the site's 200 KB limit, which nothing in the sandbox checked.
|
|
49
49
|
|
|
50
|
-
import {
|
|
50
|
+
import { spawnSync } from 'node:child_process';
|
|
51
51
|
import { existsSync } from 'node:fs';
|
|
52
52
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
53
53
|
import { join, relative, resolve } from 'node:path';
|
|
@@ -59,6 +59,8 @@ import { maxOutputTokens, models as lineup, prompts, upcomingModels } from '../b
|
|
|
59
59
|
// VB_EXTRA_MODELS, as rows shaped like bench.config.mjs's).
|
|
60
60
|
const extraModels = process.env.VB_EXTRA_MODELS ? JSON.parse(process.env.VB_EXTRA_MODELS) : [];
|
|
61
61
|
const models = [...lineup, ...upcomingModels, ...extraModels];
|
|
62
|
+
/** The ids of the containers that are up, to take down if the run is stopped. */
|
|
63
|
+
const running = new Set();
|
|
62
64
|
import { PRICE_RATIO, VIA_CHECKED, keyOf, open } from '../harness/adapters/index.mjs';
|
|
63
65
|
import { draw } from '../harness/loop.mjs';
|
|
64
66
|
import { estimate } from '../harness/prices.mjs';
|
|
@@ -67,10 +69,15 @@ import { HARNESS, firstLimits, firstRequest, limits, request, tool } from '../ha
|
|
|
67
69
|
import { IMAGE, imageId as sandboxImageId, openSandbox } from '../harness/sandbox.mjs';
|
|
68
70
|
import { ProviderError } from '../src/model-apis.js';
|
|
69
71
|
import { cleanSvg } from '../worker/svg.js';
|
|
70
|
-
import { findChrome } from './doctor.mjs';
|
|
72
|
+
import { INSTALLED, findChrome } from './doctor.mjs';
|
|
73
|
+
import { writeSheet } from './sheet.mjs';
|
|
71
74
|
|
|
72
75
|
const ROOT = fileURLToPath(new URL('../', import.meta.url));
|
|
73
76
|
const CONCURRENCY = Number(process.argv.includes('--concurrency') ? process.argv[process.argv.indexOf('--concurrency') + 1] : 3); // per provider
|
|
77
|
+
if (!Number.isInteger(CONCURRENCY) || CONCURRENCY < 1) {
|
|
78
|
+
console.error('--concurrency takes a whole number, 1 or more.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
74
81
|
|
|
75
82
|
try {
|
|
76
83
|
process.loadEnvFile(join(ROOT, '.env'));
|
|
@@ -186,20 +193,6 @@ async function readJson(path) {
|
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
195
|
|
|
189
|
-
function run(command, commandArgs, { log } = {}) {
|
|
190
|
-
return new Promise((done) => {
|
|
191
|
-
const child = spawn(command, commandArgs, { cwd: ROOT, env: process.env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
192
|
-
let out = '';
|
|
193
|
-
child.stdout.on('data', (chunk) => (out += chunk));
|
|
194
|
-
child.stderr.on('data', (chunk) => (out += chunk));
|
|
195
|
-
child.on('error', (error) => done({ code: -1, out: String(error) }));
|
|
196
|
-
child.on('close', async (code) => {
|
|
197
|
-
if (log) await writeFile(log, out);
|
|
198
|
-
done({ code, out });
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
196
|
/** Chromium on this machine: the last word on whether the file draws. */
|
|
204
197
|
async function openRenderer() {
|
|
205
198
|
const { chromium } = await import('playwright-core');
|
|
@@ -275,6 +268,7 @@ async function ask(prompt, model, renderer, imageId) {
|
|
|
275
268
|
let result;
|
|
276
269
|
try {
|
|
277
270
|
sandbox = await openSandbox({ image: version.image, commandSeconds: budget.commandSeconds });
|
|
271
|
+
running.add(sandbox.id);
|
|
278
272
|
if (probe) {
|
|
279
273
|
await sandbox.run(
|
|
280
274
|
`python3 -c "from PIL import Image, ImageDraw, ImageFont; i = Image.new('RGB', (480, 200), 'white'); ImageDraw.Draw(i).text((110, 40), '${number}', fill='black', font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 110)); i.save('probe.png')"`,
|
|
@@ -311,6 +305,7 @@ async function ask(prompt, model, renderer, imageId) {
|
|
|
311
305
|
if (probe) result.probe = { sent: number, answer: (await sandbox.read('answer.txt'))?.trim() ?? null, seen: (await sandbox.read('seen.txt'))?.trim() ?? null };
|
|
312
306
|
} finally {
|
|
313
307
|
await sandbox?.close();
|
|
308
|
+
running.delete(sandbox?.id);
|
|
314
309
|
}
|
|
315
310
|
await saveRun(folder, result);
|
|
316
311
|
|
|
@@ -470,13 +465,22 @@ ${sections.join('\n')}
|
|
|
470
465
|
);
|
|
471
466
|
}
|
|
472
467
|
|
|
468
|
+
// The plain-request drawings are in the repository, not in the npm package: without them there is nothing to compare with.
|
|
469
|
+
const COMPARES = existsSync(join(ROOT, 'drawings'));
|
|
470
|
+
|
|
471
|
+
/** index.html and manifest.json for everything in OUT, and compare.html where there is something to compare with. */
|
|
472
|
+
async function writeSheets(asked) {
|
|
473
|
+
// In a clone the manifest is what `npm run arena -- import` reads, so it lists the lineup; a partner's own model is always in.
|
|
474
|
+
await writeSheet({ out: OUT, models: INSTALLED ? models : [...lineup, ...extraModels], prompts });
|
|
475
|
+
if (COMPARES) await writeComparison(asked);
|
|
476
|
+
}
|
|
477
|
+
|
|
473
478
|
/* Run --------------------------------------------------------------------- */
|
|
474
479
|
|
|
475
480
|
const asked = probe ? [PROBE] : prompts.filter((p) => onlyPrompts.includes(p.id));
|
|
476
481
|
if (flag('sheet')) {
|
|
477
|
-
await
|
|
478
|
-
|
|
479
|
-
console.log(`Rebuilt ${shown(OUT)}/compare.html and index.html.`);
|
|
482
|
+
await writeSheets(asked);
|
|
483
|
+
console.log(`Rebuilt ${shown(OUT)}/${COMPARES ? 'compare.html and ' : ''}index.html.`);
|
|
480
484
|
process.exit(0);
|
|
481
485
|
}
|
|
482
486
|
const wanted = [];
|
|
@@ -497,7 +501,7 @@ for (const model of models.filter((m) => !onlyModels || onlyModels.includes(m.id
|
|
|
497
501
|
}
|
|
498
502
|
if (!wanted.length) {
|
|
499
503
|
console.log('Nothing to ask.');
|
|
500
|
-
if (!probe) await
|
|
504
|
+
if (!probe) await writeSheets(asked);
|
|
501
505
|
process.exit(0);
|
|
502
506
|
}
|
|
503
507
|
console.log(`${wanted.length} runs to make, into ${shown(OUT)}/:`);
|
|
@@ -507,6 +511,15 @@ if (flag('dry-run')) process.exit(0);
|
|
|
507
511
|
const imageId = await sandboxImageId(version.image);
|
|
508
512
|
if (!imageId) fail(`The sandbox image ${version.image} is missing. \`npm run partner\` (or \`vectorbench draw\`) builds it; the build command itself is in harness/Dockerfile.`);
|
|
509
513
|
|
|
514
|
+
// Stopped by hand (Ctrl-C): the containers would otherwise sit there for hours.
|
|
515
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
516
|
+
process.once(signal, () => {
|
|
517
|
+
if (running.size) spawnSync('docker', ['rm', '-f', ...running], { stdio: 'ignore' });
|
|
518
|
+
console.error(`\nStopped. The drawings that have an answer are kept: the same command picks up the rest.`);
|
|
519
|
+
process.exit(130);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
510
523
|
const renderer = await openRenderer();
|
|
511
524
|
const queues = new Map();
|
|
512
525
|
const lines = [];
|
|
@@ -540,8 +553,7 @@ await Promise.all([...queues.values()].map((tasks) => pool(tasks, CONCURRENCY)))
|
|
|
540
553
|
await renderer.close();
|
|
541
554
|
|
|
542
555
|
if (!probe) {
|
|
543
|
-
await
|
|
544
|
-
|
|
545
|
-
console.log(`\nLook them over in ${shown(OUT)}/compare.html (beside the plain-request drawings) or ${shown(OUT)}/index.html.`);
|
|
556
|
+
await writeSheets(asked);
|
|
557
|
+
console.log(`\nLook them over in ${COMPARES ? `${shown(OUT)}/compare.html (beside the plain-request drawings) or ` : ''}${shown(OUT)}/index.html.`);
|
|
546
558
|
}
|
|
547
559
|
await writeFile(join(OUT, 'summary.txt'), lines.join('\n') + '\n');
|
package/scripts/partner.mjs
CHANGED
|
@@ -42,7 +42,23 @@ const COMMAND = process.env.VB_COMMAND || 'npm run partner --';
|
|
|
42
42
|
|
|
43
43
|
loadEnv();
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const OPTIONS = ` --model <id> the model to draw with (the only one that is needed)
|
|
46
|
+
--prompt <ids> only these prompts, comma-separated: one first shows the cost (\`vectorbench prompts\` lists them)
|
|
47
|
+
--via <provider> for a model we don't list: whose API answers (${PROVIDERS.join(', ')})
|
|
48
|
+
--api-model <id> for a model we don't list: its id at that API, if it differs from --model
|
|
49
|
+
--effort <level> for a model we don't list: its highest reasoning setting, up to max
|
|
50
|
+
--name <name> for a model we don't list: what to call it
|
|
51
|
+
--codex an OpenAI model through the Codex CLI, on your ChatGPT plan (the default when OPENAI_API_KEY isn't set)
|
|
52
|
+
--grok-build an xAI model through Grok Build, on your Grok plan (the default when XAI_API_KEY isn't set)
|
|
53
|
+
--api a Claude model on ANTHROPIC_API_KEY, instead of Claude Code on your Claude plan
|
|
54
|
+
--dry-run show what would be asked and what is missing, and ask nothing
|
|
55
|
+
--out <dir> where to write
|
|
56
|
+
--concurrency <n> drawings at once (default 3)`;
|
|
57
|
+
const VALUED = ['model', 'prompt', 'via', 'api-model', 'effort', 'name', 'out', 'concurrency'];
|
|
58
|
+
const FLAGS = ['codex', 'grok-build', 'api', 'dry-run', 'help'];
|
|
59
|
+
|
|
60
|
+
// --name=value is the same as --name value.
|
|
61
|
+
const args = process.argv.slice(2).flatMap((arg) => (/^--[a-z-]+=/.test(arg) ? [arg.slice(0, arg.indexOf('=')), arg.slice(arg.indexOf('=') + 1)] : [arg]));
|
|
46
62
|
const flag = (name) => args.includes(`--${name}`);
|
|
47
63
|
const option = (name) => (args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : undefined);
|
|
48
64
|
const dryRun = flag('dry-run');
|
|
@@ -51,10 +67,25 @@ const stop = (message) => {
|
|
|
51
67
|
process.exit(1);
|
|
52
68
|
};
|
|
53
69
|
|
|
70
|
+
if (flag('help') || args.includes('-h')) {
|
|
71
|
+
console.log(`${COMMAND} --model <id> [options]\n\n${OPTIONS}\n\nThe models we list: ${[...lineup, ...upcomingModels].map((m) => m.id).join(', ')}.`);
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
// A mistyped option would otherwise be dropped without a word, and the run would not be the one that was meant.
|
|
75
|
+
for (let i = 0; i < args.length; i++) {
|
|
76
|
+
const name = args[i].startsWith('--') ? args[i].slice(2) : null;
|
|
77
|
+
if (name === null) stop(`"${args[i]}" isn't an option. The options:\n\n${OPTIONS}`);
|
|
78
|
+
if (VALUED.includes(name)) {
|
|
79
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith('--')) stop(`--${name} takes a value. The options:\n\n${OPTIONS}`);
|
|
80
|
+
i++;
|
|
81
|
+
} else if (!FLAGS.includes(name)) stop(`There is no --${name} option. The options:\n\n${OPTIONS}`);
|
|
82
|
+
}
|
|
83
|
+
if (option('concurrency') && !/^[1-9]\d*$/.test(option('concurrency'))) stop('--concurrency takes a whole number, 1 or more.');
|
|
84
|
+
|
|
54
85
|
/* The model ---------------------------------------------------------------- */
|
|
55
86
|
|
|
56
87
|
const id = option('model');
|
|
57
|
-
if (!id || id.
|
|
88
|
+
if (!id || id.includes(',')) stop(`Name one model: ${COMMAND} --model <id>\nThe ones we list: ${[...lineup, ...upcomingModels].map((m) => m.id).join(', ')}.\nAny other: add --via <${PROVIDERS.join('|')}> --effort <its highest reasoning setting>.\n\nThe options:\n\n${OPTIONS}`);
|
|
58
89
|
|
|
59
90
|
let model = [...lineup, ...upcomingModels].find((m) => m.id === id);
|
|
60
91
|
let extra = null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// The review sheet for a folder of drawings: manifest.json (what
|
|
2
|
+
// `npm run arena -- import` reads) and index.html, to look them over.
|
|
3
|
+
// scripts/generate.mjs and scripts/harness.mjs both end by writing it, and
|
|
4
|
+
// the npm package carries it, so `vectorbench draw` leaves the same sheet.
|
|
5
|
+
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
const escape = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
11
|
+
|
|
12
|
+
/** Rebuilds manifest.json and index.html in `out` from what's on disk there. Returns how many drawings it found. */
|
|
13
|
+
export async function writeSheet({ out, models, prompts }) {
|
|
14
|
+
const svgPath = (prompt, model) => join(out, prompt.id, `${model.id}.svg`);
|
|
15
|
+
const readLog = async (prompt, model) => {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(await readFile(join(out, 'log', prompt.id, `${model.id}.json`), 'utf8'));
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const entries = [];
|
|
23
|
+
const sections = [];
|
|
24
|
+
for (const prompt of prompts) {
|
|
25
|
+
const cells = [];
|
|
26
|
+
for (const model of models) {
|
|
27
|
+
const log = await readLog(prompt, model);
|
|
28
|
+
if (!log) continue;
|
|
29
|
+
if (log.outcome === 'drawn' && existsSync(svgPath(prompt, model))) {
|
|
30
|
+
// The setting this drawing was asked at, which can differ from the model's setting now.
|
|
31
|
+
entries.push({ prompt: prompt.id, model: model.id, file: `${prompt.id}/${model.id}.svg`, effort: log.effort ?? null });
|
|
32
|
+
cells.push(`<figure><img src="${prompt.id}/${model.id}.svg" alt="" loading="lazy"><figcaption>${escape(model.name)}</figcaption></figure>`);
|
|
33
|
+
} else {
|
|
34
|
+
cells.push(`<figure><p>${escape(log.outcome)}: ${escape(log.problem ?? 'no drawing')}</p><figcaption>${escape(model.name)}</figcaption></figure>`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (cells.length) sections.push(`<h2>${escape(prompt.text)}</h2>\n<div class="row">${cells.join('')}</div>`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const used = new Set(entries.map((e) => e.model));
|
|
41
|
+
const drawn = new Set(entries.map((e) => e.prompt));
|
|
42
|
+
await mkdir(out, { recursive: true });
|
|
43
|
+
await writeFile(
|
|
44
|
+
join(out, 'manifest.json'),
|
|
45
|
+
JSON.stringify(
|
|
46
|
+
{
|
|
47
|
+
models: models.filter((m) => used.has(m.id)).map(({ id, name, provider }) => ({ id, name, provider })),
|
|
48
|
+
prompts: prompts.filter((p) => drawn.has(p.id)),
|
|
49
|
+
entries,
|
|
50
|
+
},
|
|
51
|
+
null,
|
|
52
|
+
2,
|
|
53
|
+
) + '\n',
|
|
54
|
+
);
|
|
55
|
+
await writeFile(
|
|
56
|
+
join(out, 'index.html'),
|
|
57
|
+
`<!doctype html>
|
|
58
|
+
<meta charset="utf-8">
|
|
59
|
+
<title>VectorBench drawings</title>
|
|
60
|
+
<style>
|
|
61
|
+
body { margin: 32px; background: #000; color: #eef2fa; font: 15px/1.4 system-ui, sans-serif; }
|
|
62
|
+
h1 { font-weight: 300; }
|
|
63
|
+
h2 { margin: 40px 0 12px; font-size: 18px; font-weight: 500; }
|
|
64
|
+
.row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
|
|
65
|
+
figure { margin: 0; }
|
|
66
|
+
img, figure p { display: block; width: 100%; aspect-ratio: 1; margin: 0; background: #fff; object-fit: contain; }
|
|
67
|
+
figure p { display: grid; place-items: center; padding: 16px; box-sizing: border-box; background: #1a1f2b; color: #ffb4a2; text-align: center; }
|
|
68
|
+
figcaption { padding: 6px 0; color: #8c95a8; }
|
|
69
|
+
</style>
|
|
70
|
+
<h1>${entries.length} drawings to look over before importing</h1>
|
|
71
|
+
${sections.join('\n')}
|
|
72
|
+
`,
|
|
73
|
+
);
|
|
74
|
+
return entries.length;
|
|
75
|
+
}
|