Asking the image MCP for 4K through a relay came back at 2K: nothing told the model how large to draw. Settings › Models › Images now has Image resolution (Automatic, 1K, 2K, 4K; an app menu, saved as imageResolution), and generate_image takes a resolution argument. The agent's own resolution or WIDTHxHEIGHT size wins over the setting. The images API takes `resolution` (or a tier given as size, "4K"), and each vendor gets it in its own field: - Gemini: imageConfig.imageSize (3.x image models; 2.x draws at 1K); - chat image models (Gemini's): image_config.image_size; - OpenRouter /images: resolution; - Grok Imagine: resolution 1k or 2k (its largest); - Seedream (Ark): the size tier the model has, or its pixels for a ratio; - MiniMax H3: area; - GPT Image 2 and other WxH images APIs: pixels at the ratio, within GPT Image 2's limits (edge 3840, 655,360 to 8,294,400 pixels, /16); - gpt-image-1, DALL·E and SenseNova keep their own sizes. A vendor that answers 400 or 422 to a tier is asked once more without it. An unknown resolution is a 400. Both MCPs now say what size each image came back at, and when that is under the tier asked. The row is drawn by videogen.js, after Video generation's, so app.js keeps its budget (it was at 1,088,641 to the byte); the server keeps imageResolution when a save doesn't send it (TestSettingsImageResolution), so prefsKeep doesn't carry it. The menu has no notes: "The model's own" was a plugin's key already. Run (magpie-desktop WSL on xiaomi-gpu; mote was over load 18 all day): - gofmt -l: clean; go vet -tags nogui ./... and GOOS=windows go vet ./...: ok. - go test ./internal/gateway -count=1 (1995s), ./internal/imagemcp, ./internal/settings, ./internal/settingsapi: ok; at this head go vet -tags nogui of gui, gateway and settingsapi, and gateway -run "Tier|ImagesAPIResolution|ImageMCP|Draw|Image", settingsapi and imagemcp: ok. - New: draw_tier_test.go (each protocol's field, a fake upstream for the images API and the image MCP, the 400 retry, the precedence). - At this head (on88b65d758): go test -tags nogui ./internal/gui -run "Budget|I18n|SettingsImage": ok; node --test i18n-keys, image-resolution (22 of 22: chromium and webkit, en zh zh-TW ja de, 1100 and 420 wide), video-gen-pick and old-webkit: 62 of 64. The 2 reds are old-webkit's "compat.js is the first..." (guideback.js) and "the styles hold up in Safari 15.0" (app.css :has()), the same on a clean copy of origin/main88b65d758: #6570. - Broken by hand: imagesAPISize returning the size as given, the retry off, chat image_size and OpenRouter resolution dropped, the image MCP ignoring the setting, the server's keep of imageResolution removed, a zh string removed: each turned its test red. Not run yet: the full go test ./... and the whole GUI suite (WSL's one suite slot was taken by another session); they run after this push. Not tried against a real vendor.
71 lines
4.3 KiB
JavaScript
71 lines
4.3 KiB
JavaScript
// Settings › Models › Images' Video generation: the model a video request
|
||
// that names none is made with, generate_video's — the one magpie picks or
|
||
// one named. A custom provider's model makes videos once marked so in its
|
||
// Model settings (#1399), which the row says while no model makes any,
|
||
// with a way to the Providers page.
|
||
// Image generation's Off turns it off too. app.js imports this when
|
||
// Settings draws Image generation, so it weighs nothing on the core.
|
||
|
||
// videoGenFill draws the row into r
|
||
window.videoGenFill = function (r, s, keep) {
|
||
const models = s.videoGenModels || [];
|
||
const v = s.videoGen || "";
|
||
const named = namedIn(models);
|
||
const icOf = (id) => models.find((x) => x.id === id)?.icon;
|
||
const gone = v && v === s.videoGenMissing;
|
||
r.id = "videoGenRow";
|
||
r.hidden = false;
|
||
const who = el("div", "who");
|
||
who.append(el("div", "name", t("Video generation")), el("div", "sub wraps", t("The model Magpie Image makes videos with")));
|
||
if (!models.length && !v) {
|
||
// the way there: the Providers page, where a provider's models are
|
||
const how = el("div", "sub wraps video-gen-how", t("To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes › Video model"));
|
||
const go = el("button", "text video-gen-go", t("Providers") + " ›");
|
||
go.type = "button";
|
||
go.onclick = () => show("providers");
|
||
how.append(" ", go);
|
||
who.append(how);
|
||
}
|
||
if (gone) who.append(el("div", "sub err video-gen-missing", s.videoGenAuto
|
||
? t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.", { model: v, auto: named(s.videoGenAuto) })
|
||
: t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.", { model: v })));
|
||
const b = el("button", "rt-cond on");
|
||
if (gone) b.append(icon("generic"), el("span", "", v + " · " + t("missing")));
|
||
else if (v) b.append(icon(icOf(v) || "generic"), el("span", "", named(v)));
|
||
else {
|
||
if (s.videoGenAuto) b.append(icon(icOf(s.videoGenAuto) || "generic"));
|
||
b.append(el("span", "", s.videoGenAuto ? t("Automatic") + " · " + named(s.videoGenAuto) : t("Automatic") + " · " + t("no model that makes videos")));
|
||
}
|
||
b.onclick = (ev) => openPicker({ id: "", name: "", fields: [] }, { key: "videoGen", label: "model", value: v, options: [
|
||
{ value: "", label: t("Automatic"), note: s.videoGenAuto ? named(s.videoGenAuto) : t("no model that makes videos"), reset: true },
|
||
...models.map((x) => ({ value: x.id, label: x.name || x.id, note: x.providerName, icon: x.icon, group: x.providerName, ref: x.id }))],
|
||
onPick: (id) => { if (id !== v) savePrefs({ ...keep, videoGen: id }); } }, b, ev);
|
||
const val = el("div", "val");
|
||
val.append(b);
|
||
r.append(who, val);
|
||
r.after(imageResRow(s, keep));
|
||
};
|
||
|
||
// imageResRow draws Image resolution, put after Video generation's row:
|
||
// how large Magpie Image asks an image to be drawn when the agent names
|
||
// no size (skingstyle48487 on X), the model's own, 1K, 2K or 4K, which
|
||
// the gateway asks each vendor for in its own field
|
||
function imageResRow(s, keep) {
|
||
const r = el("div", "row pref"), tiers = [["", "Automatic"], ["1K", "1K"], ["2K", "2K"], ["4K", "4K"]], who = el("div", "who"), val = el("div", "val"), n = t("Image resolution");
|
||
r.id = "imageResolutionRow";
|
||
who.append(el("div", "name", n), el("div", "sub wraps", t("How large images are drawn when the agent names no size. A model that can't draw that large draws at its own")));
|
||
const cur = tiers.find(([v]) => v === (s.imageResolution || "")) || tiers[0], b = el("button", "sess-pick image-resolution");
|
||
b.type = "button";
|
||
b.title = n;
|
||
menuOpener(b);
|
||
b.append(el("span", "", t(cur[1])), svg(CHEV, 11, 1.6));
|
||
b.onclick = (e) => {
|
||
e.stopPropagation();
|
||
if (b.classList.contains("open")) return closeProtoMenu();
|
||
openProtoMenu(b, tiers.map(([v, name]) => ({ v, name, note: "", literalName: !!v })), cur[0], (v) => v !== cur[0] && savePrefs({ ...keep, imageResolution: v }), "Image resolution", "sess-menu", "right");
|
||
};
|
||
val.append(b);
|
||
r.append(who, val);
|
||
return r;
|
||
}
|