Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Ideogram 4 declines go straight to the fallback models

Adarshaec8e40011b6
diff --git a/src/components/library/asset-card.tsx b/src/components/library/asset-card.tsx
index f401aff9..7b8bae32 100644
--- a/src/components/library/asset-card.tsx
+++ b/src/components/library/asset-card.tsx
@@ -298,7 +298,7 @@ export const AssetCard = memo(function AssetCard({
{/* "Rendering", as the Status filter calls it: "In progress" is a review status. */}
{!stack && g.status !== "succeeded" && ` · ${listStatus(g)}`}
</p>
- {/* What made a run of Auto ("Auto · made with Ideogram 4"), and what changed while it ran ("Made with Qwen-Image 2.1 · Ideogram 4 declined this one"). */}
+ {/* What made a run of Auto ("Auto · made with Ideogram 4"), and what changed while it ran ("Made with Krea 2 Realism · Ideogram 4 declined this one"). */}
{!stack && autoLine(g) && <p className="truncate text-[12px] text-muted-foreground">{autoLine(g)}</p>}
{!stack && g.request.notice && <p className="truncate text-[12px] text-muted-foreground">{g.request.notice}</p>}
{/* An account's own GPU or key: the way out, in the row (its thumbnail is too small for it). */}
diff --git a/src/components/studio/made-note.tsx b/src/components/studio/made-note.tsx
index 1f43d5f8..32132e2d 100644
--- a/src/components/studio/made-note.tsx
+++ b/src/components/studio/made-note.tsx
@@ -9,7 +9,7 @@ type NoteRun = Pick<Generation, "declinedCards" | "status" | "modelId" | "modelN
/**
* Under a run (the feed card, the run details): what made a run of Auto ("Auto · made
- * with Krea 2 Realism · Ideogram 4 declined this one"), what changed while it ran (its notice: "Made with Qwen-Image 2.1 ·
+ * with Krea 2 Realism · Ideogram 4 declined this one"), what changed while it ran (its notice: "Made with Krea 2 Realism ·
* Ideogram 4 declined this one"), and, for the owner's eyes only, what Ideogram 4 returned in place of a picture, for
* which words. A setting a model makes differently is said before the run, where it can still be changed; after the run
* the views show only the value it was made at (shownSettings), never a value the studio didn't offer.
diff --git a/src/lib/ideogram-caption.ts b/src/lib/ideogram-caption.ts
index 655e9ace..d1c90258 100644
--- a/src/lib/ideogram-caption.ts
+++ b/src/lib/ideogram-caption.ts
@@ -116,7 +116,7 @@ export function parseCaption(text: string): string | null {
}
/**
- * A caption's words as plain text, for a model that reads plain words (Qwen-Image 2.1 making a run Ideogram 4 declined):
+ * A caption's words as plain text, for a model that reads plain words (a fallback making a run Ideogram 4 declined):
* its lead, its scene, then each element's words. Plain words come back as they are.
*/
export function captionWords(text: string): string {
diff --git a/src/server/generations.ts b/src/server/generations.ts
index c44acb43..aa0d4608 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -67,7 +67,7 @@ import { qwen21Gpu } from "./qwen21-gpu";
import { h3Gpu } from "./h3-gpu";
import { H3_TIER_PARAM, H3_UNET_PARAM } from "@/lib/gpu/h3-tier";
import { DETAILS_MAX_IMAGES, GPU_PARAM, QWEN21_SPEED, speedLora } from "@/lib/qwen21-speed";
-import { BLOCKED_CARD_MESSAGE, blockedMeasures, DECLINED_FALLBACK_MODEL, DECLINED_NOTICE, DECLINED_WORDS } from "./safety-card";
+import { BLOCKED_CARD_MESSAGE, blockedMeasures, declinedNotice, LEGACY_DECLINED } from "./safety-card";
import { pollTrainings } from "./training";
import { createEndFrameClip, createExtendChain, createKeyframeFilm, createMosaicRun, createRefinedModel, createRelitClip, createShotFilm, createStillTo3d, createVoiceFirst, joinClips } from "./chains";
import { chainedRefine } from "@/lib/av/hi3d";
@@ -229,8 +229,8 @@ export function toGeneration(r: Row): Generation {
"SELECT (SELECT deleted_at FROM generation_trash WHERE generation_id = ?) AS deleted_at, (SELECT folder_id FROM folder_items WHERE generation_id = ?) AS folder_id",
)
.get(r.id, r.id) as { deleted_at: number | null; folder_id: string | null });
- // An Ideogram 4 run that returned its "blocked" card (declinedAgain), made again in its place: Working, saying which try
- // it is on (never In line: nobody pressed Run again). One that waits for the account's own GPU to come back shows that.
+ // An Ideogram 4 run that returned its "blocked" card (declinedAgain), made again in its place: Working, saying which model
+ // makes it (never In line: nobody pressed Run again). One that waits for the account's own GPU to come back shows that.
const meta = r.external_meta_json?.includes('"declined"') ? readMeta(r.external_meta_json) : undefined;
const again = (r.status === "queued" || r.status === "running") && !(r.status === "queued" && !r.external_id && meta?.heal) ? declinedWords(meta ?? {}) : undefined;
return {
@@ -517,23 +517,24 @@ interface PendingMeta {
/** Who holds the run as the release before this one marked it (OLD_LEASE), and until when. */
lease?: { by?: unknown; until?: unknown };
/**
- * An Ideogram 4 run that returned only its "blocked" card (declinedAgain): which try it is on now (`stage`: made again
- * with a new seed, then with Qwen-Image 2.1), and the cards it returned (kept for the owner). Kept through every hand-over.
+ * An Ideogram 4 run that returned only its "blocked" card (declinedAgain): the fallback that makes it now, and the
+ * cards it returned (kept for the owner). Kept through every hand-over.
*/
declined?: DeclinedMeta;
}
/** What an Ideogram 4 run that returned its "blocked" card keeps (PendingMeta.declined). */
interface DeclinedMeta {
- stage?: keyof typeof DECLINED_WORDS;
- /** A run of Auto: the fallback model that makes it now (src/lib/auto-image.ts AUTO_FALLBACKS). */
+ /** "fallback": a fallback makes it now. "retry": only on runs declined before (LEGACY_DECLINED). */
+ stage?: "retry" | "fallback";
+ /** The fallback model that makes it now (src/lib/auto-image.ts AUTO_FALLBACKS); none on a legacy Qwen-Image 2.1 run. */
model?: string;
cards?: DeclinedCard[];
- /** Made with Qwen-Image 2.1 now: the run as Ideogram 4's, put back when that fails too (declinedFails). */
+ /** The run as Ideogram 4's, put back when every fallback fails (declinedFails). */
was?: DeclinedRun;
}
-/** The columns of a run that Qwen-Image 2.1 changes when it makes a run Ideogram 4 declined. */
+/** The columns of a run that a fallback changes when it makes a run Ideogram 4 declined. */
type DeclinedRun = Pick<Row, "request_json" | "model_id" | "engine" | "op" | "kind" | "prompt" | "cost_usd">;
const declinedRun = (r: Row): DeclinedRun => ({ request_json: r.request_json, model_id: r.model_id, engine: r.engine, op: r.op, kind: r.kind, prompt: r.prompt, cost_usd: r.cost_usd });
@@ -2764,7 +2765,7 @@ async function pause(id: string, ms: number): Promise<boolean> {
* account's own run, logged and noted for the owner (run-events.ts).
*/
function failRun(id: string, e: unknown, trouble: Diagnosis | undefined, account: string | undefined, facts?: RunFacts, own = !!facts): boolean {
- // Qwen-Image 2.1 making a run Ideogram 4 declined: it fails as the declined run.
+ // A fallback making a run Ideogram 4 declined: the next one, or it fails as the declined run.
const declined = declinedFails(id, trouble?.words ?? String((e as Error | null)?.message ?? e));
if (declined !== null) return declined;
const fix = (e as { fix?: GenerationFix } | null)?.fix;
@@ -3076,9 +3077,10 @@ function resend(r: Row, account: string, words: string): boolean {
/** The words an Ideogram 4 run made again after it declined shows while it works; undefined for any other run. */
function declinedWords(meta: PendingMeta | Record<string, unknown>): string | undefined {
const d = (meta as PendingMeta).declined;
- if (!d?.stage || !Object.hasOwn(DECLINED_WORDS, d.stage)) return undefined;
- // Auto's fallbacks name the model that makes it now.
- return d.stage === "fallback" && d.model ? `Making it with ${getModel(d.model)?.name ?? d.model}` : DECLINED_WORDS[d.stage];
+ if (d?.stage === "retry") return LEGACY_DECLINED.retryWords;
+ if (d?.stage !== "fallback") return undefined;
+ const m = d.model ?? LEGACY_DECLINED.model;
+ return `Making it with ${getModel(m)?.name ?? m}`;
}
/**
@@ -3092,11 +3094,10 @@ function keepForOwner(assetIds: readonly string[]): void {
}
/**
- * What another model is asked when it makes a run Ideogram 4 declined (Qwen-Image 2.1, or one of Auto's fallbacks): the
- * same words in plain text (a caption given as the prompt becomes its words), the same pictures, aspect ratio, size and
- * count, and the model's own settings.
+ * What one of Auto's fallbacks is asked when it makes a run Ideogram 4 declined: the same words in plain text (a caption
+ * given as the prompt becomes its words), the same pictures, aspect ratio, size and count, and the model's own settings.
*/
-function declinedFallback(stored: GenerationRequest, modelId: string = DECLINED_FALLBACK_MODEL): GenerationRequest {
+function declinedFallback(stored: GenerationRequest, modelId: string): GenerationRequest {
const p = stored.params ?? {};
return {
...stored,
@@ -3115,13 +3116,12 @@ function declinedFallback(stored: GenerationRequest, modelId: string = DECLINED_
/**
* An Ideogram 4 run whose every picture was its "blocked" card is made again in its place: the same run (its id, its
* place, its turn in the line, its billing hold), as the same job of its batch, through the same submit as every run
- * (this install's workers, the owner's ComfyUI, an account's own GPU). Ideogram 4 picked by name: first Ideogram 4 once
- * more, with the same caption and a new seed (its refusals are often random); then Qwen-Image 2.1 (declinedFallback), and
- * the run names the model that made it (its model and its request's notice). A run of Auto (src/lib/auto-image.ts):
- * never Ideogram 4 again, but its fallbacks in order (Krea 2 Realism, FIBO 2 Dev, MOSS-Image), each only when the one
- * before fails (declinedFails), its pick saying why (`why: "declined"`). None is a new press of Run: no limit counts it
- * again, and no new row or hold is made. The run's tile says which try it is on. False when every try was made already,
- * or none can go where the run went: the run fails as before. `later`: sent once the caller (a submit that failed) has
+ * (this install's workers, the owner's ComfyUI, an account's own GPU), never by Ideogram 4 again: Auto's fallbacks in
+ * order (src/lib/auto-image.ts: Krea 2 Realism, FIBO 2 Dev, MOSS-Image), the next one switched on that goes where the run
+ * went, each only when the one before fails (declinedFails). A run of Auto keeps Auto, its pick saying why
+ * (`why: "declined"`); Ideogram 4 picked by name names the model that made it (its model and its request's notice).
+ * None is a new press of Run: no limit counts it again, and no new row or hold is made. The run's tile says which model
+ * makes it. False when none is left: the run fails as before. `later`: sent once the caller (a submit that failed) has
* let go of the run.
*/
function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {
@@ -3136,49 +3136,35 @@ function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {
: account
? asAccount(account, () => prepare(req))
: prepare(req);
- let next: "retry" | "fallback";
let asked = stored;
let model: string | undefined;
let p: ReturnType<typeof prepare> | undefined;
- if (auto) {
- // The next of Auto's fallbacks that is switched on and goes where the run went.
- for (let m = nextAutoFallback(declined.model); m && !p; m = nextAutoFallback(m)) {
- const ask: GenerationRequest = { ...declinedFallback(stored, m), modelId: AUTO_IMAGE, auto: { model: m, why: "declined" } };
- try {
- const q = planned(ask);
- if (q.providerId === r.provider) [p, asked, model] = [q, ask, m];
- } catch {
- // Switched off, or it can't make this run: the next one.
- }
- }
- if (!p) return false;
- next = "fallback";
- } else {
- const n = !declined.stage ? "retry" : declined.stage === "retry" ? "fallback" : null;
- if (!n) return false;
- next = n;
- if (next === "retry") {
- p = planned(stored);
- // The caption it ran with (never written again), and a new seed.
- const caption = r.prompt ? parseCaption(r.prompt) : null;
- p = { ...p, plan: { ...p.plan, ...(caption && { prompt: caption }), params: { ...p.plan.params, seed: crypto.randomInt(0, 2 ** 31) } } };
- } else {
- asked = declinedFallback(stored);
- try {
- p = planned(asked);
- } catch {
- // A preset with no Qwen-Image 2.1 version: its words as they were planned, without the preset.
- const words = captionWords(planned(stored).plan.prompt);
- asked = { ...asked, presetId: undefined, presetOptions: undefined, signature: undefined, prompt: words };
- p = planned(asked);
+ // A legacy "retry" stage has no model: it starts at the first fallback.
+ for (let m = nextAutoFallback(declined.model); m && !p; m = nextAutoFallback(m)) {
+ let ask: GenerationRequest = auto ? { ...declinedFallback(stored, m), modelId: AUTO_IMAGE, auto: { model: m, why: "declined" } } : declinedFallback(stored, m);
+ let q: ReturnType<typeof prepare> | undefined;
+ try {
+ q = planned(ask);
+ } catch {
+ // A preset with no version for this model: its words as they were planned, without the preset.
+ if (stored.presetId) {
+ try {
+ ask = { ...ask, presetId: undefined, presetOptions: undefined, signature: undefined, prompt: captionWords(planned(stored).plan.prompt) };
+ q = planned(ask);
+ } catch {
+ // Switched off, or it can't make this run: the next one.
+ }
}
}
- if (p.providerId !== r.provider) return false;
+ if (q && q.providerId === r.provider) [p, asked, model] = [q, ask, m];
}
+ if (!p || !model) return false;
const go = p;
const index = jobIndexOf(r, readMeta(r.external_meta_json));
// The run as Ideogram 4's stays kept from the first fallback on (declinedFails puts it back).
- const now: DeclinedMeta = { ...declined, stage: next, ...(model && { model }), ...(next === "fallback" && { was: declined.was ?? declinedRun(r) }) };
+ const was = declined.was ?? declinedRun(r);
+ const now: DeclinedMeta = { ...declined, stage: "fallback", model, was };
+ const notice = (JSON.parse(was.request_json) as GenerationRequest).notice;
const fields: Partial<Row> = {
external_id: null,
external_meta_json: JSON.stringify({ jobIndex: index, declined: now }),
@@ -3186,16 +3172,14 @@ function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {
status: "running",
progress: null,
message: declinedWords({ declined: now }) ?? null,
- ...(next === "fallback" && {
- model_id: go.plan.model.id,
- engine: go.plan.model.engine,
- op: go.plan.op,
- kind: outputKind(go.plan.op, go.plan.model),
- prompt: go.plan.prompt,
- cost_usd: go.cost,
- // Auto's own line says what made it (autoLine); Ideogram 4 picked by name carries the notice.
- request_json: JSON.stringify(auto ? asked : { ...asked, notice: [stored.notice, DECLINED_NOTICE].filter(Boolean).join(" · ") }),
- }),
+ model_id: go.plan.model.id,
+ engine: go.plan.model.engine,
+ op: go.plan.op,
+ kind: outputKind(go.plan.op, go.plan.model),
+ prompt: go.plan.prompt,
+ cost_usd: go.cost,
+ // Auto's own line says what made it (autoLine); Ideogram 4 picked by name carries the notice.
+ request_json: JSON.stringify(auto ? asked : { ...asked, notice: [notice, declinedNotice(go.plan.model.name)].filter(Boolean).join(" · ") }),
};
// (Only while the run still goes and is still the job that declined or failed: one another app process saved, ended or
// sent again meanwhile is left as it is.) It takes its turn to be sent in the same step, and its finish turn goes.
@@ -3219,7 +3203,7 @@ function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {
}
/**
- * The model that made a run Ideogram 4 declined couldn't make it either. A run of Auto goes on to its next fallback
+ * The model that made a run Ideogram 4 declined couldn't make it either. The run goes on to its next fallback
* (declinedAgain) while there is one. Otherwise the run fails as Ideogram 4's (its model, request and words put back, so
* Retry runs what was asked), saying what to try, whether its job failed or couldn't be sent. What the model said goes
* to the log. Null: not such a run; else whether the run was failed here (false: it still went, or goes on).
@@ -3228,7 +3212,8 @@ function declinedFails(id: string, said: string, metaJson?: string | null): bool
const json = metaJson !== undefined ? metaJson : (db().prepare("SELECT external_meta_json FROM generations WHERE id = ?").pluck().get(id) as string | null | undefined);
const was = readMeta(json).declined;
if (was?.stage !== "fallback") return null;
- console.warn(`[generations] ${id}: ${getModel(was.model ?? DECLINED_FALLBACK_MODEL)?.name ?? was.model} after Ideogram 4 declined: ${said.slice(0, 500)}`);
+ const tried = was.model ?? LEGACY_DECLINED.model;
+ console.warn(`[generations] ${id}: ${getModel(tried)?.name ?? tried} after Ideogram 4 declined: ${said.slice(0, 500)}`);
if (was.model && nextAutoFallback(was.model)) {
const r = db().prepare("SELECT * FROM generations WHERE id = ?").get(id) as Row | undefined;
if (r && (r.status === "queued" || r.status === "running") && declinedAgain(r, was, true)) return false;
@@ -4353,7 +4338,7 @@ async function pollOne(r: Row): Promise<void> {
if (res.state === "failed") {
// Its GPU restarted and lost the job: an account's run is sent again once, as a computer's tab does.
if (own && res.lost && resend(r, own, RESENT_WORDS)) return;
- // Qwen-Image 2.1 making a run Ideogram 4 declined: it fails as the declined run.
+ // A fallback making a run Ideogram 4 declined: the next one, or it fails as the declined run.
if (declinedFails(r.id, res.error, r.external_meta_json) !== null) return;
// An account's run: its own GPU's words (comfyui.ts), or its key's provider's read plainly; the provider's own words
// go in the details line. The owner's runs keep the provider's words.
@@ -4497,7 +4482,7 @@ async function pollOne(r: Row): Promise<void> {
}
// Ideogram 4's grey "blocked by safety filter" card is no picture (src/server/safety-card.ts): it is left out of the
// results and kept for the owner only (keepForOwner), with its measures. A run that got some real pictures keeps them.
- // A run whose every picture was the card is made again in its place (declinedAgain: a new seed, then Qwen-Image 2.1);
+ // A run whose every picture was the card is made again in its place (declinedAgain: Auto's fallbacks in order);
// only when it can't be does it fail, saying what to try.
if (model.options.promptFormat === "ideogram4") {
const cards = new Map<OutputFile, DeclinedCard>();
diff --git a/src/server/run-details.ts b/src/server/run-details.ts
index bbc03cd2..c0b0f9b1 100644
--- a/src/server/run-details.ts
+++ b/src/server/run-details.ts
@@ -225,7 +225,7 @@ export interface RunMoney {
export interface RunMadeBy {
/** A run of Auto: the model it picked, and why. */
auto?: { model: string; name: string; why: AutoWhy; words: string };
- /** Ideogram 4 declined it: where its retries stand, and the model that made it in its place. */
+ /** Ideogram 4 declined it: its stage, and the model that made it in its place. */
declined?: { stage?: string; words: string; model?: string; modelName?: string; askedModel?: string; askedModelName?: string };
/** What changed while it ran (an optional input left out, another model made it), said on the result. */
notices: string[];
@@ -494,7 +494,7 @@ export const AUTO_WHY_WORDS: Record<AutoWhy, string> = {
const DECLINED_STAGE_WORDS: Record<string, string> = {
retry: "Ideogram 4 declined it and was asked again with a new seed",
- fallback: "Ideogram 4 declined it twice, so another model made it",
+ fallback: "Ideogram 4 declined it, so another model made it",
};
/** How a run was made: Auto's pick, Ideogram 4's declines and the model after them, and the notices it carries. */
diff --git a/src/server/safety-card.ts b/src/server/safety-card.ts
index 5994b6f3..70443c17 100644
--- a/src/server/safety-card.ts
+++ b/src/server/safety-card.ts
@@ -47,16 +47,12 @@ export function looksBlocked(png: Buffer): boolean {
}
/**
- * An Ideogram 4 run whose every picture was the card is made again once with a new seed (its refusals are often
- * random), then with Qwen-Image 2.1, before it fails (src/server/generations.ts declinedAgain): the model of the second
- * try, the words each try shows while it works, and the line a run the second try made carries (its request's notice).
+ * An Ideogram 4 run whose every picture was the card is made by Auto's fallbacks in order (src/server/generations.ts
+ * declinedAgain). The notice a run picked by name carries once one of them made it.
*/
-export const DECLINED_FALLBACK_MODEL = "oss-qwen-image-21";
-export const DECLINED_WORDS = {
- retry: "Ideogram 4 is trying again",
- fallback: "Making it with Qwen-Image 2.1",
-} as const;
-export const DECLINED_NOTICE = "Made with Qwen-Image 2.1 · Ideogram 4 declined this one";
+export const declinedNotice = (modelName: string): string => `Made with ${modelName} · Ideogram 4 declined this one`;
+/** Runs declined before that: stage "retry" (Ideogram 4 with a new seed), then a fallback with no model (Qwen-Image 2.1). */
+export const LEGACY_DECLINED = { retryWords: "Ideogram 4 is trying again", model: "oss-qwen-image-21" } as const;
/**
* The card's measures of a picture, for the owner's note on a declined run: `spread`, how far its colours spread (the mean
diff --git a/tests/auto-image-runs.test.ts b/tests/auto-image-runs.test.ts
index f49e3d76..c108516e 100644
--- a/tests/auto-image-runs.test.ts
+++ b/tests/auto-image-runs.test.ts
@@ -5,8 +5,8 @@ import { tempDir } from "./helpers/temp-dir";
// Auto's runs: each is planned on the model Auto picks (Ideogram 4, Krea 2 Realism for the owner's patterns, Qwen-Image 2.1
// for an edit) and keeps Auto with its pick. When Ideogram 4 answers a run of Auto with its grey card, Krea 2 Realism, then
-// FIBO 2 Dev, then MOSS-Image make the same run (never Ideogram 4 again), and only then does it fail. A model picked by
-// name keeps today's way (tests/ideogram-declined.test.ts). Its rules alone: tests/auto-image.test.ts.
+// FIBO 2 Dev, then MOSS-Image make the same run (never Ideogram 4 again), and only then does it fail. Ideogram 4 picked
+// by name goes the same way (tests/ideogram-declined.test.ts). Its rules alone: tests/auto-image.test.ts.
vi.setConfig({ testTimeout: 60_000 });
const dir = tempDir("fuobe-auto-image-runs-");
process.env.FUOBE_DATA_DIR = dir;
@@ -18,7 +18,7 @@ const { setSetting, getSetting, validateSetting } = await import("@/server/setti
const { createGenerations, getGeneration, previewGeneration } = await import("@/server/generations");
const { mockProvider } = await import("@/server/providers/mock");
const { changeAccess } = await import("@/server/model-access");
-const { BLOCKED_CARD_MESSAGE, DECLINED_NOTICE } = await import("@/server/safety-card");
+const { BLOCKED_CARD_MESSAGE, declinedNotice } = await import("@/server/safety-card");
const { encodePng } = await import("@/server/png");
const { db } = await import("@/server/db");
const { AUTO_IMAGE, DEFAULT_AUTO_PATTERNS } = await import("@/lib/auto-image");
@@ -179,7 +179,7 @@ describe("Auto after Ideogram 4 declines", () => {
expect(handed[1].run.message).toBe("Making it with Krea 2 Realism");
expect(rowsSince(g.id)).toBe(1);
expect(line(g)).toContain("Auto · made with Krea 2 Realism · Ideogram 4 declined this one");
- expect(line(g)).not.toContain(DECLINED_NOTICE);
+ expect(line(g)).not.toContain(declinedNotice("Krea 2 Realism"));
// The owner's own run: the card, the words, and Add a pattern.
expect(g.declinedCards).toHaveLength(1);
expect(line(g)).toContain("Words: “a red fox in deep snow”");
@@ -230,11 +230,12 @@ describe("Auto after Ideogram 4 declines", () => {
expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-fibo2-dev"]);
});
- it("Ideogram 4 picked by name keeps its own way: once more, then Qwen-Image 2.1", async () => {
- ideogram = [[card], [card]];
+ it("Ideogram 4 picked by name takes the same fallbacks, and stays a run of that model with a notice", async () => {
+ ideogram = [[card]];
const g = await run("a red fox in deep snow", {}, "oss-ideogram-4");
- expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-ideogram-4", "oss-qwen-image-21"]);
- expect(g.request.notice).toBe(DECLINED_NOTICE);
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism"]);
+ expect(g.request.modelId).toBe("oss-krea2-realism");
+ expect(g.request.notice).toBe(declinedNotice("Krea 2 Realism"));
expect(g.request.auto).toBeUndefined();
});
});
diff --git a/tests/ideogram-declined-pool.test.ts b/tests/ideogram-declined-pool.test.ts
index 5b8a6f1d..c8cb68ab 100644
--- a/tests/ideogram-declined-pool.test.ts
+++ b/tests/ideogram-declined-pool.test.ts
@@ -6,7 +6,7 @@ import { tempDir } from "./helpers/temp-dir";
/**
* An account's free Ideogram 4 run on this install's GPUs that comes back as the grey "blocked" card is made again in its
- * place, on the same GPUs: once more with a new seed, then with Qwen-Image 2.1. One press of Run stays one run: the
+ * place, on the same GPUs, by Auto's fallbacks (Krea 2 Realism first). One press of Run stays one run: the
* hourly count, the runs at once and the billing hold count it once, and the billing service gets one report for it.
* The cards are for the owner only (Accounts' runs), never the account's. (The rules themselves on the owner's runs:
* tests/ideogram-declined.test.ts.)
@@ -51,7 +51,7 @@ const { loadIndex } = await import("@/server/gpu/index-file");
const { allLanes } = await import("@/lib/lanes");
const { getGeneration } = await import("@/server/generations");
const { listAccountRuns } = await import("@/server/account-admin");
-const { DECLINED_NOTICE, DECLINED_WORDS } = await import("@/server/safety-card");
+const { declinedNotice } = await import("@/server/safety-card");
const { encodePng } = await import("@/server/png");
const HOST = "localhost:3000";
@@ -163,38 +163,36 @@ afterEach(() => {
});
describe("an account's free Ideogram 4 run on this install's GPUs that comes back as the card", () => {
- it("is made again there, then by Qwen-Image 2.1, and counts as one run", async () => {
+ it("is made there by Krea 2 Realism, and counts as one run", async () => {
const a = account();
accountId = a.id;
- ideogram = [[card], [card]];
+ ideogram = [[card]];
const r = await post({ feature: "image", modelId: "oss-ideogram-4", prompt: "a red fox in deep snow", params: { aspectRatio: "4:5" } }, a.cookie);
expect(r.status, JSON.stringify(r.body)).toBe(201);
const id = r.body.items![0].id;
const g = await settled(id);
expect(g.status, g.error ?? "").toBe("succeeded");
expect(g.place).toBe("pool");
- expect(g.modelId).toBe("oss-qwen-image-21");
- expect(g.request.notice).toBe(DECLINED_NOTICE);
+ expect(g.modelId).toBe("oss-krea2-realism");
+ expect(g.request.notice).toBe(declinedNotice("Krea 2 Realism"));
expect(g.outputs).toHaveLength(1);
- // Three jobs, all for the one run, on the same GPUs.
+ // Two jobs, both for the one run, on the same GPUs: no second Ideogram 4 try.
expect(sent.map((s) => [s.model, s.id])).toEqual([
["oss-ideogram-4", id],
- ["oss-ideogram-4", id],
- ["oss-qwen-image-21", id],
+ ["oss-krea2-realism", id],
]);
// While it was made again, its tile said Working in plain words, and it was still one run going, let in once.
expect(sent[1].tile.status).toBe("running");
- expect(sent[1].tile.message).toBe(DECLINED_WORDS.retry);
+ expect(sent[1].tile.message).toBe("Making it with Krea 2 Realism");
expect(sent[1].tile.queue).toBeUndefined();
- expect(sent[2].tile.message).toBe(DECLINED_WORDS.fallback);
- expect(sent.map((s) => s.going)).toEqual([1, 1, 1]);
- expect(sent.map((s) => s.hourly)).toEqual([1, 1, 1]);
+ expect(sent.map((s) => s.going)).toEqual([1, 1]);
+ expect(sent.map((s) => s.hourly)).toEqual([1, 1]);
expect(admitted(a.id)).toBe(1);
expect(rowsOf(a.id)).toBe(1);
// The account never sees what Ideogram 4 returned; the owner does, in Accounts' runs.
expect(g.declinedCards).toBeUndefined();
const listed = listAccountRuns({ account: a.id }).items.find((x) => x.id === id)!;
- expect(listed.declinedCards).toHaveLength(2);
+ expect(listed.declinedCards).toHaveLength(1);
});
it("with a billing service: one hold, and one report for the run", async () => {
@@ -203,15 +201,15 @@ describe("an account's free Ideogram 4 run on this install's GPUs that comes bac
billing.resetBillingCache();
const a = account();
accountId = a.id;
- ideogram = [[card], [gradient]];
+ ideogram = [[card]];
const reserves = fake.calls_of("/v1/reserve").length;
const r = await post({ feature: "image", modelId: "oss-ideogram-4", prompt: "a lighthouse at dusk", shown: { amount: 7, priceVersion: "v7" } }, a.cookie);
expect(r.status, JSON.stringify(r.body)).toBe(201);
const id = r.body.items![0].id;
const g = await settled(id);
expect(g.status, g.error ?? "").toBe("succeeded");
- expect(g.modelId).toBe("oss-ideogram-4");
- expect(sent.map((s) => s.model)).toEqual(["oss-ideogram-4", "oss-ideogram-4"]);
+ expect(g.modelId).toBe("oss-krea2-realism");
+ expect(sent.map((s) => s.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism"]);
expect(fake.calls_of("/v1/reserve").length - reserves).toBe(1);
expect(admitted(a.id)).toBe(1);
queueReports();
diff --git a/tests/ideogram-declined.test.ts b/tests/ideogram-declined.test.ts
index a94f72a6..cf572c66 100644
--- a/tests/ideogram-declined.test.ts
+++ b/tests/ideogram-declined.test.ts
@@ -3,9 +3,10 @@ import { renderToStaticMarkup } from "react-dom/server";
import type { GenInput, Generation } from "@/lib/catalog/types";
import { tempDir } from "./helpers/temp-dir";
-// An Ideogram 4 run whose every picture is its grey "blocked" card is made again in its place: once more with a new seed,
-// then with Qwen-Image 2.1, and only then does it fail. A run with some real pictures keeps them, as before. The cards are
-// kept for the owner only. (Runs on this install's GPUs, and their limits: tests/ideogram-declined-pool.test.ts.)
+// An Ideogram 4 run whose every picture is its grey "blocked" card is made again in its place by Auto's fallbacks in order
+// (Krea 2 Realism, FIBO 2 Dev, MOSS-Image; never Ideogram 4 again), and only then does it fail. A run with some real
+// pictures keeps them, as before. The cards are kept for the owner only. (Runs on this install's GPUs, and their limits:
+// tests/ideogram-declined-pool.test.ts.)
vi.setConfig({ testTimeout: 60_000 });
const dir = tempDir("fuobe-ideogram-declined-");
process.env.FUOBE_DATA_DIR = dir;
@@ -16,7 +17,7 @@ delete process.env.ANTHROPIC_API_KEY;
const { setSetting } = await import("@/server/settings");
const { createGenerations, getGeneration } = await import("@/server/generations");
const { mockProvider } = await import("@/server/providers/mock");
-const { BLOCKED_CARD_MESSAGE, DECLINED_NOTICE, DECLINED_WORDS, blockedMeasures } = await import("@/server/safety-card");
+const { BLOCKED_CARD_MESSAGE, blockedMeasures, declinedNotice } = await import("@/server/safety-card");
const { encodePng } = await import("@/server/png");
const { getAsset, listAssets } = await import("@/server/storage");
const { db } = await import("@/server/db");
@@ -35,9 +36,11 @@ const card = png(640, 480, (x, y) => (y > 232 && y < 248 && x > 180 && x < 460 &
const gradient = png(640, 480, (x, y) => [Math.round((x / 639) * 255), Math.round((y / 479) * 255), 128]);
const dataUri = (b: Buffer) => `data:image/png;base64,${b.toString("base64")}`;
-/** Ideogram 4's answer to each job it is sent, in order (its pictures); Qwen-Image 2.1 makes its own, or fails. */
+/** Ideogram 4's answer to each job it is sent, in order (its pictures); the fallbacks make their own, or fail. */
let ideogram: Buffer[][] = [];
-let qwenFails = false;
+let failing = new Set<string>();
+/** Meta the next Ideogram 4 job is sent with (a run declined before the change, still going). */
+let sentMeta: Record<string, unknown> | undefined;
/** Each job handed to the provider: which model, what it got, and how the run read at that moment. */
let handed: { model: string; input: GenInput; run: Generation }[] = [];
const submit = mockProvider.submit;
@@ -48,12 +51,16 @@ beforeAll(() => setSetting("demoMode", "auto"));
beforeEach(() => {
setSetting("enhanceProvider", "none");
ideogram = [];
- qwenFails = false;
+ failing = new Set();
+ sentMeta = undefined;
handed = [];
answers.clear();
mockProvider.submit = async (ctx) => {
handed.push({ model: ctx.model.id, input: ctx.input, run: getGeneration(ctx.generationId)! });
- return submit(ctx);
+ const res = await submit(ctx);
+ const meta = ctx.model.id === "oss-ideogram-4" ? sentMeta : undefined;
+ sentMeta = undefined;
+ return meta ? { ...res, meta: { ...res.meta, ...meta } } : res;
};
mockProvider.poll = async (ctx) => {
if (ctx.model.id === "oss-ideogram-4") {
@@ -61,7 +68,7 @@ beforeEach(() => {
if (!pics) answers.set(ctx.externalId, (pics = ideogram.shift() ?? [gradient]));
return { state: "succeeded", outputs: pics.map((p) => ({ url: dataUri(p), kind: "image" as const })) };
}
- if (ctx.model.id === "oss-qwen-image-21" && qwenFails) return { state: "failed", error: "Out of memory on the GPU" };
+ if (failing.has(ctx.model.id)) return { state: "failed", error: "Out of memory on the GPU" };
return poll(ctx);
};
});
@@ -98,23 +105,28 @@ describe("Ideogram 4 that declines a run", () => {
expect(blockedMeasures(Buffer.from("not a picture"))).toBeNull();
});
- it("runs once more with a new seed, as the same run, and keeps what it made then", async () => {
- ideogram = [[card], [gradient]];
- const g = await run({ seed: 41 });
+ it("Krea 2 Realism makes it at once, as the same run, from the same words, in the same shape, and the run says so", async () => {
+ ideogram = [[card]];
+ const g = await run({ aspectRatio: "16:9", resolution: "1.5K", seed: 41, extra: { preset: "Turbo" } });
expect(g.status, g.error ?? "").toBe("succeeded");
- expect(g.modelId).toBe("oss-ideogram-4");
+ // No second Ideogram 4 try, and no Qwen-Image 2.1.
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism"]);
+ expect(handed[0].input.prompt).toBe(captionFromWords("a red fox in deep snow"));
+ expect(g.modelId).toBe("oss-krea2-realism");
+ expect(g.modelName).toBe("Krea 2 Realism");
+ expect(g.request.modelId).toBe("oss-krea2-realism");
+ expect(g.request.auto).toBeUndefined();
+ expect(g.request.notice).toBe("Made with Krea 2 Realism · Ideogram 4 declined this one");
expect(g.outputs).toHaveLength(1);
- expect(g.request.notice).toBeUndefined();
- // Two jobs of the one run: the same caption, a new seed; the second said what it was doing while it worked.
- const jobs = handed.filter((h) => h.model === "oss-ideogram-4");
- expect(jobs).toHaveLength(2);
- expect(jobs[1].input.prompt).toBe(jobs[0].input.prompt);
- expect(jobs[0].input.prompt).toBe(captionFromWords("a red fox in deep snow"));
- expect(jobs[0].input.seed).toBe(41);
- expect(jobs[1].input.seed).not.toBe(41);
- expect(jobs[1].run.status).toBe("running");
- expect(jobs[1].run.message).toBe(DECLINED_WORDS.retry);
expect(rowsLike(g.id)).toBe(1);
+ // Plain words (never the caption), the shape and size asked, none of Ideogram 4's own settings.
+ const krea = handed[1];
+ expect(krea.input.prompt).toBe("a red fox in deep snow");
+ expect(krea.input.aspectRatio).toBe("16:9");
+ expect(krea.input.resolution).toBe("1.5K");
+ expect(krea.input.extra?.preset).toBeUndefined();
+ expect(krea.run.status).toBe("running");
+ expect(krea.run.message).toBe("Making it with Krea 2 Realism");
// The card stays with the run for the owner: held (no account and no link serves it), out of every file list.
expect(g.declinedCards).toHaveLength(1);
const kept = filesOf(g.id).map((id) => getAsset(id)!).find((a) => a.url === g.declinedCards![0].url)!;
@@ -122,41 +134,32 @@ describe("Ideogram 4 that declines a run", () => {
expect(fileAccount(kept.relPath)).toBe(HELD_FILE);
expect(listAssets({ limit: 1000 }).some((a) => a.id === kept.id)).toBe(false);
expect(g.outputs.some((o) => o.url === kept.url)).toBe(false);
- });
-
- it("declined again: Qwen-Image 2.1 makes it, from the same words, in the same shape, and the run says so", async () => {
- ideogram = [[card], [card]];
- const g = await run({ aspectRatio: "16:9", resolution: "1.5K", extra: { preset: "Turbo" } });
- expect(g.status, g.error ?? "").toBe("succeeded");
- expect(g.modelId).toBe("oss-qwen-image-21");
- expect(g.modelName).toBe("Qwen-Image 2.1");
- expect(g.request.notice).toBe(DECLINED_NOTICE);
- expect(g.outputs).toHaveLength(1);
- expect(rowsLike(g.id)).toBe(1);
- const qwen = handed.filter((h) => h.model === "oss-qwen-image-21");
- expect(qwen).toHaveLength(1);
- // Plain words (never the caption), the shape and size asked, none of Ideogram 4's own settings.
- expect(qwen[0].input.prompt).toBe("a red fox in deep snow");
- expect(qwen[0].input.aspectRatio).toBe("16:9");
- expect(qwen[0].input.resolution).toBe("1.5K");
- expect(qwen[0].input.extra?.preset).toBeUndefined();
- expect(qwen[0].run.message).toBe(DECLINED_WORDS.fallback);
- expect(qwen[0].run.status).toBe("running");
- // Both cards are the owner's to look at.
- expect(g.declinedCards).toHaveLength(2);
// The tile's one plain line, and the owner's line with what Ideogram 4 returned.
const html = renderToStaticMarkup(MadeNote({ g })!);
- expect(html).toContain("Made with Qwen-Image 2.1 · Ideogram 4 declined this one");
+ expect(html).toContain("Made with Krea 2 Realism · Ideogram 4 declined this one");
expect(html).toContain("Ideogram 4 declined: what it returned");
// Someone else's eyes (an account's own run never carries the cards): only the plain line.
const theirs = renderToStaticMarkup(MadeNote({ g: { ...g, declinedCards: undefined } })!);
- expect(theirs).toContain(DECLINED_NOTICE);
+ expect(theirs).toContain(declinedNotice("Krea 2 Realism"));
expect(theirs).not.toContain("what it returned");
});
- it("when Qwen-Image 2.1 can't make it either, the run fails as Ideogram 4's, in the words it always had", async () => {
- ideogram = [[card], [card]];
- qwenFails = true;
+ it("each next fallback only when the one before fails, and the notice names the one that made it", async () => {
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism"]);
+ const g = await run();
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev"]);
+ expect(g.modelId).toBe("oss-fibo2-dev");
+ expect(g.request.notice).toBe(declinedNotice("FIBO 2 Dev"));
+ expect(handed[2].input.prompt).toBe("a red fox in deep snow");
+ expect(handed[2].run.message).toBe("Making it with FIBO 2 Dev");
+ expect(rowsLike(g.id)).toBe(1);
+ });
+
+ it("when every fallback fails too, the run fails as Ideogram 4's, in the words it always had", async () => {
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
const g = await run();
expect(g.status).toBe("failed");
expect(g.error).toBe(BLOCKED_CARD_MESSAGE);
@@ -165,13 +168,23 @@ describe("Ideogram 4 that declines a run", () => {
expect(g.modelId).toBe("oss-ideogram-4");
expect(g.request.modelId).toBe("oss-ideogram-4");
expect(g.request.notice).toBeUndefined();
- expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-ideogram-4", "oss-qwen-image-21"]);
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
expect(rowsLike(g.id)).toBe(1);
- // No result kept; the two cards stay for the owner, and go with the run.
- expect(g.declinedCards).toHaveLength(2);
+ // No result kept; the card stays for the owner, and goes with the run.
+ expect(g.declinedCards).toHaveLength(1);
expect(listAssets({ source: "generation", limit: 1000 }).filter((a) => a.generationId === g.id)).toEqual([]);
});
+ it("a run declined before the change, on its second Ideogram 4 try: declined again, it goes to the first fallback", async () => {
+ ideogram = [[card]];
+ sentMeta = { declined: { stage: "retry", cards: [] } };
+ const g = await run();
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism"]);
+ expect(g.modelId).toBe("oss-krea2-realism");
+ expect(g.request.notice).toBe(declinedNotice("Krea 2 Realism"));
+ });
+
it("some real pictures and some cards: the real ones are kept and nothing runs again", async () => {
ideogram = [[card, gradient]];
const g = await run();
diff --git a/tests/open-ideogram-4.test.ts b/tests/open-ideogram-4.test.ts
index 6da629cb..66ba2005 100644
--- a/tests/open-ideogram-4.test.ts
+++ b/tests/open-ideogram-4.test.ts
@@ -425,11 +425,11 @@ describe("Ideogram 4's grey safety card", () => {
it("never keeps the card as a result: the run is made again in its place (tests/ideogram-declined.test.ts)", async () => {
const g = await answered(card);
expect(g.status, g.error ?? "").toBe("succeeded");
- expect(g.modelId).toBe("oss-qwen-image-21");
+ expect(g.modelId).toBe("oss-krea2-realism");
expect(g.outputs).toHaveLength(1);
// The card is no result of the run (only the owner's held copy is kept with it).
expect(listAssets({ source: "generation", limit: 1000 }).filter((a) => a.generationId === g.id)).toHaveLength(1);
- expect(g.declinedCards?.length).toBe(2);
+ expect(g.declinedCards?.length).toBe(1);
});
it("keeps a real picture", async () => {
diff --git a/tests/run-details.test.ts b/tests/run-details.test.ts
index 498812d5..64b19f43 100644
--- a/tests/run-details.test.ts
+++ b/tests/run-details.test.ts
@@ -190,14 +190,14 @@ describe("Run details: the owner's view of one account's run", () => {
const card = { url: "/api/files/held/card.png", spread: 3, grey: 0.97 };
const id = run(A, {
status: "succeeded",
- request: { notice: "Made with Qwen-Image 2.1 · Ideogram 4 declined this one" },
- meta: { jobIndex: 0, declined: { stage: "fallback", cards: [card], was: { model_id: "oss-ideogram-4", request_json: "{}" } } },
+ request: { modelId: "oss-krea2-realism", notice: "Made with Krea 2 Realism · Ideogram 4 declined this one" },
+ meta: { jobIndex: 0, declined: { stage: "fallback", model: "oss-krea2-realism", cards: [card], was: { model_id: "oss-ideogram-4", request_json: "{}" } } },
});
const d = (await (await get(id)).json()) as RunDetails;
expect(d.run.declinedCards).toEqual([card]);
- expect(d.madeBy.declined).toMatchObject({ stage: "fallback", askedModel: "oss-ideogram-4" });
- expect(d.madeBy.notices).toEqual(["Made with Qwen-Image 2.1 · Ideogram 4 declined this one"]);
- expect(d.model).toMatchObject({ id: "oss-ideogram-4", ranOn: { id: "oss-qwen-image-21" } });
+ expect(d.madeBy.declined).toMatchObject({ stage: "fallback", words: "Ideogram 4 declined it, so another model made it", askedModel: "oss-ideogram-4", model: "oss-krea2-realism", modelName: "Krea 2 Realism" });
+ expect(d.madeBy.notices).toEqual(["Made with Krea 2 Realism · Ideogram 4 declined this one"]);
+ expect(d.model).toMatchObject({ id: "oss-ideogram-4", ranOn: { id: "oss-krea2-realism" } });
});
it("gives the timeline, its jobs and workers, and what it cost, without its hold or lease", async () => {