14 lines
1.1 KiB
JavaScript
14 lines
1.1 KiB
JavaScript
import { randomInt, createHash, randomUUID } from 'node:crypto';
|
|
import { PNG } from 'pngjs';
|
|
|
|
// Synthetic pixels only. The expected order is never placed in the prompt.
|
|
export function visionProbe() {
|
|
const colors = [{name:'RED',rgb:[230,0,0]},{name:'GREEN',rgb:[0,180,0]},{name:'BLUE',rgb:[0,0,230]},{name:'YELLOW',rgb:[240,220,0]}];
|
|
for (let i=colors.length-1;i>0;i--) { const j=randomInt(i+1);[colors[i],colors[j]]=[colors[j],colors[i]]; }
|
|
const png=new PNG({width:128,height:128});
|
|
for(let y=0;y<128;y++)for(let x=0;x<128;x++)png.data.set([...colors[(y>=64?2:0)+(x>=64?1:0)].rgb,255],(y*128+x)*4);
|
|
const bytes=PNG.sync.write(png);
|
|
return {expected:colors.map(value=>value.name).join(','),prompt:'Read the four colored squares in this attached synthetic image in order: top-left, top-right, bottom-left, bottom-right. Reply only with four comma-separated English color names, using RED, GREEN, BLUE, YELLOW. Do not call tools.',
|
|
image:{id:randomUUID(),sha256:createHash('sha256').update(bytes).digest('hex'),width:128,height:128,dataUrl:'data:image/png;base64,'+bytes.toString('base64')}};
|
|
}
|