Files
vscode-workbench/mcp-demo/probe-vision2.mjs
T

49 lines
2.1 KiB
JavaScript

// Re-probe vision on models that errored or returned empty, with a proper
// 64x64 PNG. Also probes the clearly-vision-named models the user has NOT
// configured, to show what they are missing.
import { readFileSync } from "node:fs";
const cred = readFileSync("C:/Users/12914/.dsh/.credentials.yaml", "utf8");
function refKey(name) { const m = cred.match(new RegExp(`\\s${name}: ([^\\s]+)`)); return m ? m[1] : ""; }
const IMG = readFileSync("C:/Users/12914/Desktop/vscode/mcp-demo/img64.b64", "utf8").trim();
const targets = [
{ name: "b", base: "http://156.225.30.43:65423/bai/v1", key: refKey("B_API_KEY"),
models: ["glm-5.3-flash", "hy3", "mimo-v2.5", "deepseek-v4-flash-vision-exp", "gemini-3.8-flash"] },
{ name: "command-code", base: "https://api.commandcode.ai/provider/v1", key: refKey("COMMAND_CODE_API_KEY"),
models: ["z-ai/glm-5.3-flash", "xiaomi/mimo-v2.5", "meituan/LongCat-2.0:free", "deepseek/deepseek-v4-flash-vision-exp", "google/gemini-3.8-flash"] }
];
for (const p of targets) {
for (const model of p.models) {
const ctl = new AbortController();
const t = setTimeout(() => ctl.abort(), 45000);
try {
const r = await fetch(`${p.base}/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${p.key}` },
body: JSON.stringify({
model,
messages: [{ role: "user", content: [
{ type: "text", text: "What color is this image? One word." },
{ type: "image_url", image_url: { url: `data:image/png;base64,${IMG}` } }
] }],
max_tokens: 32
}),
signal: ctl.signal
});
const text = await r.text();
let j = null; try { j = JSON.parse(text); } catch {}
const ok = r.status === 200 && j?.choices?.length;
console.log(JSON.stringify({
provider: p.name, model,
vision: ok ? "YES" : (r.status === 0 ? "TIMEOUT" : "no"),
note: ok ? (j.choices[0].message?.content ?? "").slice(0, 40) : (j?.error?.message ?? text.slice(0, 80))
}));
} catch (e) {
console.log(JSON.stringify({ provider: p.name, model, vision: "TIMEOUT", note: `${e}`.slice(0, 60) }));
} finally { clearTimeout(t); }
}
}
console.log("DONE");