ecbot on Discord (11-06): "只有一个GPT image 这样无法确定它生图走了2还是2.5
还是2.6啊 这个有其他的配置方案吗". ChatGPT's images backend picks the GPT Image
version itself, whatever model is named, and neither the reply's body nor
its headers say which one (#1865, from a real Pro account). So magpie can't
show it or let it be chosen. Settings › Images and the provider editor's
Image models said only that one GPT Image is listed. They now say the
version isn't told, and that an OpenAI API key, whose provider lists
gpt-image-2, 2.5 and 2.6 apart, is the way to choose one. en, zh, zh-TW,
ja and de.
Run (mote, before rebasing on 8ee85c59f; budget and GUI rerun after):
- node --test of images-codex-one, chatgpt-image-chip, context-tune and
settings-lines-wrap, in Chromium and WebKit, in every language: 322 pass,
0 fail.
- After the rebase, images-codex-one's Chromium half went red at line 137
(the picker's current row has no box) in 2 of 3 runs on a busy mote. A
fresh origin/main 8ee85c59f was red the same way in 3 of 3 (#4618, its
numbers added there). WebKit passed.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestTune': ok (core
1,533,798 of 1,533,802, not raised).
Broken by hand: nothing; this is a wording change, and the tests check the
new words in every language.
Not tried: probing a real ChatGPT account's images reply in this change (the
live ~/.codex is off limits); this rests on #1865's probe.
Reported-by: ecbot
118 lines
6.8 KiB
JavaScript
118 lines
6.8 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// StarBits on X: a ChatGPT (Codex) account's editor showed its one image
|
|
// model as "gpt-image-2", read as an old model, while its backend draws
|
|
// with the model ChatGPT picks whichever is named (#1865). The chip shows
|
|
// the model's name, GPT Image, with the id as its tooltip, and unticking
|
|
// it still saves the id. A key's image model with no name of its own
|
|
// shows its id. Every language, wide and at a phone's width; the API is
|
|
// faked here.
|
|
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 fetched = new Date(Date.now() - 3600e3).toISOString();
|
|
|
|
function codex(hidden) {
|
|
return {
|
|
id: "codex", name: "Codex", icon: "codex-color", host: "", chat: "", responses: "https://chatgpt.com/backend-api/codex", anthropic: "", catalog: "",
|
|
models: [{ id: "gpt-6-astra", name: "GPT-6-Astra", on: true }], chosen: [], fetched, agents: [], fallback: [], headers: {},
|
|
key: { set: false, masked: "", optional: true }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", ready: true,
|
|
draws: 1, drawIds: ["gpt-image-2"], drawNames: { "gpt-image-2": "GPT Image" }, drawPicks: true, hiddenDrawers: hidden,
|
|
};
|
|
}
|
|
|
|
function openai() {
|
|
return {
|
|
id: "openai", name: "OpenAI", icon: "openai", host: "", chat: "https://api.openai.com/v1", responses: "", anthropic: "", catalog: "",
|
|
models: [{ id: "gpt-6", name: "GPT-6", on: true }], chosen: [], fetched, agents: [], fallback: [], headers: {},
|
|
key: { set: true, masked: "sk-…one", optional: false }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", ready: true,
|
|
draws: 2, drawIds: ["gpt-image-2.6-sunburst", "gpt-image-2"], drawNames: { "gpt-image-2.6-sunburst": "GPT Image 2.6 Sunburst" }, hiddenDrawers: [],
|
|
};
|
|
}
|
|
|
|
function serve(lang, saves) {
|
|
let hidden = [];
|
|
const providers = () => ({ providers: [codex(hidden), openai()], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
|
return async (route) => {
|
|
const req = route.request(), url = new URL(req.url());
|
|
const json = (data) => route.fulfill({ json: data });
|
|
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true,textSize:100};` });
|
|
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 } });
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/providers") return json(providers());
|
|
if (url.pathname === "/api/provider/save") {
|
|
const body = req.postDataJSON();
|
|
saves.push(body.hiddenDrawers);
|
|
if (body.hiddenDrawers) hidden = body.hiddenDrawers;
|
|
return json(providers());
|
|
}
|
|
if (url.pathname === "/api/usage/quotas") return json([]);
|
|
if (url.pathname === "/api/groups") return json({ groups: [], pools: [], models: [] });
|
|
if (url.pathname === "/api/gateway/trace") return json({ routes: [] });
|
|
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
|
|
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)];
|
|
const body = await fs.readFile(file).catch(() => null);
|
|
await (body ? route.fulfill({ body, contentType }) : route.fulfill({ status: 404, body: "" }));
|
|
};
|
|
}
|
|
|
|
const words = {
|
|
en: { save: "Save", hint: /ChatGPT's image backend picks the GPT Image version itself/ },
|
|
zh: { save: "保存", hint: /ChatGPT 的生图后端自己决定用哪个 GPT Image 版本/ },
|
|
"zh-TW": { save: "儲存", hint: /ChatGPT 的生圖後端自己決定用哪個 GPT Image 版本/ },
|
|
ja: { save: "保存", hint: /ChatGPT の画像生成バックエンドは/ },
|
|
de: { save: "Speichern", hint: /Das Bild-Backend von ChatGPT wählt die GPT-Image-Version selbst/ },
|
|
};
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(engine + ": a ChatGPT account's image model shows as GPT Image", async (t) => {
|
|
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
for (const lang of Object.keys(words)) {
|
|
const w = words[lang];
|
|
for (const width of [1000, 360]) {
|
|
await t.test(`${lang} at ${width}px`, async () => {
|
|
const saves = [];
|
|
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", serve(lang, saves));
|
|
await page.goto("http://magpie.test/?view=providers");
|
|
const editor = page.locator("#modal:not([hidden]) .editor");
|
|
const chips = editor.locator(".mchips.drawers .mchip");
|
|
const texts = () => chips.evaluateAll((cs) => cs.map((c) => [c.textContent, c.title]));
|
|
const open = async (name) => {
|
|
await page.locator(".row.provider", { hasText: name }).first().click();
|
|
await chips.first().waitFor();
|
|
};
|
|
|
|
await open("Codex");
|
|
await editor.getByText(w.hint).waitFor();
|
|
assert.deepEqual(await texts(), [["GPT Image", "gpt-image-2"]]);
|
|
assert.equal(await editor.getByText("gpt-image-2", { exact: true }).count(), 0, "the id isn't shown");
|
|
await chips.first().click();
|
|
assert.equal(await chips.first().getAttribute("aria-pressed"), "false");
|
|
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), 0);
|
|
await editor.getByRole("button", { name: w.save, exact: true }).click();
|
|
await editor.waitFor({ state: "detached" });
|
|
assert.deepEqual(saves.at(-1), ["gpt-image-2"], "unticking saves the id");
|
|
|
|
await open("OpenAI");
|
|
assert.deepEqual(await texts(), [["GPT Image 2.6 Sunburst", "gpt-image-2.6-sunburst"], ["gpt-image-2", ""]]);
|
|
assert.deepEqual(errors, []);
|
|
await page.context().close();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|