TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { pngDataUrl, post, save, short } from "./lib.ts";23const img32 = pngDataUrl(32);4const results: Record<string, any> = {};5const ask = (model: string, url: string, asObject = false) =>6 post("/chat/completions", {7 model,8 max_tokens: 100,9 messages: [10 {11 role: "user",12 content: [13 { type: "text", text: "Describe this image in one sentence: colours and shapes." },14 { type: "image_url", image_url: asObject ? { url, detail: "high" } : url },15 ],16 },17 ],18 });1920for (const model of ["mistral-large-latest", "mistral-medium-latest", "mistral-small-latest", "ministral-8b-latest", "codestral-latest", "glm-5-2"]) {21 const r = await ask(model, img32);22 const b: any = r.body;23 console.log(`${model.padEnd(24)} 32px string-url ${r.status} usage=${JSON.stringify(b?.usage)} ${short(b?.choices?.[0]?.message?.content ?? b, 200)}`);24 results[model] = r;25}26const obj = await ask("mistral-small-latest", img32, true);27console.log("small object-form {url,detail}", obj.status, JSON.stringify((obj.body as any)?.usage), short((obj.body as any)?.choices?.[0]?.message?.content ?? obj.body, 150));28results.objectForm = obj;29const tiny = await ask("mistral-small-latest", pngDataUrl(2));30console.log("small 2x2", tiny.status, JSON.stringify((tiny.body as any)?.usage), short((tiny.body as any)?.choices?.[0]?.message?.content ?? tiny.body, 200));31results.tiny = tiny;32const big = await ask("mistral-small-latest", pngDataUrl(512));33console.log("small 512x512", big.status, JSON.stringify((big.body as any)?.usage), short((big.body as any)?.choices?.[0]?.message?.content ?? big.body, 200));34results.big = big;35const bad = await ask("mistral-small-latest", "data:image/png;base64,AAAA");36console.log("small invalid png", bad.status, short(bad.body, 300));37results.bad = bad;38save("05-vision.json", results);39