SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
2.6 KB · 27 lines typescript
Raw Blame History
1// (f) vision: 32x32 PNG data URL on all 3 models (expect 400 on non-vision); tiny 2x2; detail:low; image in system message.2import { raw, MODELS, save, pngDataUrl } from "./lib.ts";34const out: Record<string, unknown> = {};5const img32 = pngDataUrl(32, 32);6for (const model of MODELS) {7  const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model, max_tokens: 200, thinking: { type: "disabled" }, messages: [{ role: "user", content: [{ type: "text", text: "Describe this image in one sentence (colors, pattern)." }, { type: "image_url", image_url: { url: img32 } }] }] }) });8  const b: any = r.body;9  out[`${model}|32x32`] = { status: r.status, content: b.choices?.[0]?.message?.content, usage: b.usage, error: r.status !== 200 ? b : undefined };10  console.log(model, "32x32 →", r.status, JSON.stringify(b.choices?.[0]?.message?.content ?? b).slice(0, 200), JSON.stringify(b.usage ?? ""));11}12const v = "deepseek-v4-flash-vision-exp";13for (const [name, body] of Object.entries({14  "2x2": { messages: [{ role: "user", content: [{ type: "text", text: "What color?" }, { type: "image_url", image_url: { url: pngDataUrl(2, 2) } }] }] },15  "detail=low": { messages: [{ role: "user", content: [{ type: "text", text: "What color?" }, { type: "image_url", image_url: { url: img32, detail: "low" } }] }] },16  "detail=original": { messages: [{ role: "user", content: [{ type: "text", text: "What color?" }, { type: "image_url", image_url: { url: img32, detail: "original" } }] }] },17  "image_in_system": { messages: [{ role: "system", content: [{ type: "text", text: "You see:" }, { type: "image_url", image_url: { url: img32 } }] }, { role: "user", content: "What color?" }] },18  "thinking+image": { thinking: { type: "enabled" }, reasoning_effort: "low", messages: [{ role: "user", content: [{ type: "text", text: "Dominant colors? one sentence." }, { type: "image_url", image_url: { url: img32 } }] }] },19  "bad_image_bytes": { messages: [{ role: "user", content: [{ type: "text", text: "What color?" }, { type: "image_url", image_url: { url: "data:image/png;base64,AAAA" } }] }] },20})) {21  const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: v, max_tokens: 200, thinking: { type: "disabled" }, ...body }) });22  const b: any = r.body;23  out[`${v}|${name}`] = { status: r.status, content: b.choices?.[0]?.message?.content, reasoning_len: b.choices?.[0]?.message?.reasoning_content?.length ?? null, usage: b.usage, error: r.status !== 200 ? b : undefined };24  console.log(v, name, "→", r.status, JSON.stringify(b.choices?.[0]?.message?.content ?? b).slice(0, 160), JSON.stringify(b.usage ?? ""));25}26save("05-vision.json", out);27