Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models (kenari/*:free) had no window, reply limit, vision or reasoning known, and there was no one place to say them. magpie model spec <provider/model> what it has, and whose each value is magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto] magpie model spec '<provider>/*' --context <n> --output <n> magpie model spec <provider/model> --reset magpie model specs It writes the stores magpie model context/output/images/efforts write (providers.json contexts; settings.json modelOutputs, modelImages, modelEfforts, modelReasonless), so every reader that went by those goes by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's /api/providers badges and chips, and the agents' model lists. Every part is checked before anything is written; a refused command writes nothing. Agents are told once. Readers that bypassed the stores and now honour them: - provider.Efforts returns the kept levels, so the gateway fits a request to them (fitEffort): xhigh asked of a model kept to low-high goes as high. This reverses #92 (47e12df41), which narrowed only the lists handed out; docs/subsystems/gateway-routing.md says so. - entryFor: levels given a model with none known make it Reasoning. - gateway AutoVision picks by the user's ModelImages (seesAt). - GUI gateway client: a reasonless model offers no level chips. Run at this tree (basea93190ae1): - go test -count=1 -timeout 45m ./internal/{provider,cli,gui,gateway, settings,tui,agent,catalog}: all ok (gateway 505s, agent 360s). - GUI: gateway-*.test.cjs, model-reasonless, plugin-gateway, i18n-keys (25 files, both engines, the new file at 1100 and 420 in en, zh, zh-TW, ja, de): 225/225 pass. app.js untouched. - gofmt -l empty; go vet darwin, linux -tags nogui, windows clean. - Sandbox HOME, built binary, `magpie web` on 47821/47820 and a fake Chat vendor on 47811: before, kenari/glm-5:free had no window or levels; after spec 128k/16k/on/low-high, /v1/models said 128000, 16000, image input, [low medium high]; max_tokens 100000 went as 16000, xhigh as high, low as low; qwen-x with --reasoning off was sent no reasoning field; /api/providers had context 128000, output 16000, images/imageSet, kept [low medium high], reasonless for qwen-x. A models.dev sync during the run (GLM-5 202752/131072) didn't move the spec; after --reset the vendor's values came back. Bad values, an unknown flag and --help wrote nothing (files hashed). Rebased ontoa6a3dbde8(the ZCode mover's min, one line): at the pushed head 5af093d8b's tree, ./internal/provider and ./internal/cli -timeout 45m ok, and the spec tests in gateway and gui ok. Broken by hand, each went red: AutoVision on raw sees; Efforts on the full list; the Reasoning line removed; output, vision or context not written; ParseLevels skipped; agents told twice; --context 0 taken; help printing modelUsage; old client.js; the GUI named() image and reasonless branches. Not tried / not changed: no full go test ./... (another session's full GUI suite was running). Codex's ChatGPT-model /models pass-through and the Codex effort dropdown read catalog.Codex(), not a spec. The TUI shows no spec badges. A Context-tab trace keeps the window it was recorded with. Pre-existing and the same on origin/maina6a3dbde8: a GLM-5 relay with no levels known has xhigh sent as high.
77 lines
4.4 KiB
JavaScript
77 lines
4.4 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// Dani Ariyanto on Discord (magpie model spec --reasoning off): a model the
|
|
// user said takes no reasoning field is offered no levels by the gateway,
|
|
// so the Gateway page's row says none, though its list has some. The
|
|
// backend sends such a model reasonless with no kept levels; the row went
|
|
// back to all the list's levels. Every language, at a wide and a narrow
|
|
// window.
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
|
|
const assets = path.resolve(__dirname, "../assets");
|
|
const providers = {
|
|
providers: [
|
|
{ id: "kenari", name: "Kenari", icon: "generic", agents: [], models: [
|
|
{ id: "glm-5", name: "glm-5", on: true, efforts: ["low", "medium", "high"], reasonless: true, images: false, context: 128000 },
|
|
{ id: "qwen-x", name: "qwen-x", on: true, efforts: ["low", "medium", "high"], images: false, context: 64000 },
|
|
] },
|
|
],
|
|
gateway: { running: true, window: true, mine: true, url: "http://127.0.0.1:3999", models: 2, calls: [], groups: [] },
|
|
};
|
|
|
|
function serve(lang) {
|
|
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
|
return async (route) => {
|
|
const url = new URL(route.request().url());
|
|
const json = (data) => route.fulfill({ json: data });
|
|
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:${JSON.stringify(lang)},theme:"light",web:true};` });
|
|
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (url.pathname === "/api/state") return json(state);
|
|
if (url.pathname === "/api/providers") return json(providers);
|
|
if (url.pathname === "/api/groups") return json({ groups: [] });
|
|
if (url.pathname === "/api/gateway/trace") {
|
|
if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3));
|
|
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
|
|
}
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
|
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
|
await route.fulfill({ body: await fs.readFile(file), contentType });
|
|
};
|
|
}
|
|
|
|
const rowOf = (page, id) => page.locator("#gwModels .row.model").filter({ has: page.locator(".name", { hasText: new RegExp("^" + id.replace(/[./]/g, "\\$&") + "$") }) });
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const width of [1100, 420]) {
|
|
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
|
test(`${engine} ${width} ${lang}: a model sent no reasoning field shows no levels on the Gateway page`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
|
const page = await (await browser.newContext({ viewport: { width, height: 800 }, reducedMotion: "reduce" })).newPage();
|
|
t.after(async () => {
|
|
if (process.env.ARTIFACT_DIR) {
|
|
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
|
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${width}-${lang}-gw-reasonless.png`) });
|
|
}
|
|
await browser.close();
|
|
});
|
|
page.setDefaultTimeout(5000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", serve(lang));
|
|
await page.goto("http://magpie.test/?view=gateway");
|
|
await page.locator("#gwModels .row.model").first().waitFor();
|
|
const chips = async (id) => (await rowOf(page, id).locator(".minfo .badge").allTextContents()).map((s) => s.trim());
|
|
const levels = await chips("kenari/qwen-x");
|
|
assert.equal(levels.length, 2, "a model with its levels says them: " + levels);
|
|
assert.equal(levels[1], "64K");
|
|
assert.deepEqual(await chips("kenari/glm-5"), ["128K"], "no levels for a model sent no reasoning field");
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|
|
}
|