import { pngDataUrl, post, save, short } from "./lib.ts"; const img32 = pngDataUrl(32); const results: Record = {}; const ask = (model: string, url: string, asObject = false) => post("/chat/completions", { model, max_tokens: 100, messages: [ { role: "user", content: [ { type: "text", text: "Describe this image in one sentence: colours and shapes." }, { type: "image_url", image_url: asObject ? { url, detail: "high" } : url }, ], }, ], }); for (const model of ["mistral-large-latest", "mistral-medium-latest", "mistral-small-latest", "ministral-8b-latest", "codestral-latest", "glm-5-2"]) { const r = await ask(model, img32); const b: any = r.body; console.log(`${model.padEnd(24)} 32px string-url ${r.status} usage=${JSON.stringify(b?.usage)} ${short(b?.choices?.[0]?.message?.content ?? b, 200)}`); results[model] = r; } const obj = await ask("mistral-small-latest", img32, true); console.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)); results.objectForm = obj; const tiny = await ask("mistral-small-latest", pngDataUrl(2)); console.log("small 2x2", tiny.status, JSON.stringify((tiny.body as any)?.usage), short((tiny.body as any)?.choices?.[0]?.message?.content ?? tiny.body, 200)); results.tiny = tiny; const big = await ask("mistral-small-latest", pngDataUrl(512)); console.log("small 512x512", big.status, JSON.stringify((big.body as any)?.usage), short((big.body as any)?.choices?.[0]?.message?.content ?? big.body, 200)); results.big = big; const bad = await ask("mistral-small-latest", "data:image/png;base64,AAAA"); console.log("small invalid png", bad.status, short(bad.body, 300)); results.bad = bad; save("05-vision.json", results);