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.

Image studio: Auto picks the open image model for each run

Adarshe3cd87576d8c
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 785f0ef7..03ec1006 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -69,6 +69,7 @@ Feed, Library, studios (React Query caches patched by id; polls every 10 s while
| `studio-packs.generated.ts` | Round 4 part 5. The 14 Photodump / Instadump packs and the 6 Fashion Factory templates (name, photo or shot count, description). **Generated** by `scripts/gen-studio-packs.py` from the research in `parity-image-studios.json`. It replaces the retired provider's generated presets file, which went with its generated models file and their generators (see Retired models); the Soul preset fallback list and `presetPrompt` left `packs.ts` with it |
| `replaced.ts` | Round 4 part 5 (O7). What replaced each retired model, training target and lost operation, pure and browser-safe: `REPLACED_BY` (12 model ids → the model that does the job now, with `was`, the name it ran under, a `note`, and `original`, `ops`, `withReferences` and `director` where they apply), `TRAINING_REPLACED_BY`, `OPS_REPLACED_BY`, `replacedBy`, `currentModelId`, `replacementOf` and `migrateRequest` (see Retired models) |
| `models.ts` | Open-source models (ComfyUI workflow ids), fal utility models (Join clips, and the hidden Extract frame, Crop to size, Mix voice and music, Level audio, Forced Alignment), the browser-only models (`local` provider: Color Grade, Ad compositor) + the generated cloud lists (whose hidden chain helpers include Trim video, Add soundtrack, Voice timeline and Extract soundtrack). A launch price (`Pricing.promo`) stays beside the list price (see `promo.ts`): the catalog never reads the clock. Since round 4 part 3 `MODELS` starts with the Fuobe Originals: `original()` joins each one's ComfyUI routes to its generated cloud half. Since round 4 part 5 the cloud list is `CLOUD_MODELS` and the cloud tools only (no retired provider's models or routes are joined, and the hand-written `ai-influencer` is gone), and two hidden open models run Character Swap Studio's graphs: `oss-h3-swap-segment` (`video-swap` on `video-character-swap-h3-segment`) and `oss-h3-person-mask` (`bg-remove-video` on `video-mask-h3-relay`). Since round 5 part 1 `originals` holds the eight new Originals' GPU halves, `oss-video-depth-vda-large` joins the open list, the hidden `oss-face-mosaic` (`face-mosaic` on `image-face-mosaic-sam3`) is the face mosaic's GPU step, and `oss-tryon-klein` carries the try-on LoRA in `ModelOptions.loras`, so its switch governs it. Since round 5 part 2 the open list gains `oss-moss-image` (MOSS-Image, `t2i` on `moss-image-t2i`; layout `moss`; a Quality control whose values each stand for several settings through `controls[].sets`, `MOSS_QUALITY`: Standard 25 steps, CFG 2.5, `er_sde`; Best 50 steps, CFG 3, euler; Fast 8 steps, CFG 1 on the 8-step DMD file) and `oss-dbs-separate` (DBS, `separate-audio` on `separate-soundtrack-dbs`: `separationModel`, Fast or Best, with no default so the host picks, and `channels`), and the hidden `oss-uni3c-path` (Wan 2.1 + Uni3C, `camera-path` on `wan21-i2v-uni3c-path`, which needs the still and the path's render: `requires.video`). Round 5 part 3 adds 16 open models (Kandinsky 6.0, Kandinsky VSR and VRMBG 3.0 are also hosted, as separate cloud models; the cloud's Bria matte is VRMBG 3.0): `oss-kandinsky6` (`t2v` on `kandinsky6-t2av`, `i2v` on `kandinsky6-i2av`; 5 s at 480p with sound; Quality Lite or Pro sets the transformer file through `controls[].sets`; an opt-in Prompt helper), `oss-kandinsky6-vsr` (`upscale-video` on `video-upscale-kandinsky6-vsr`, 2x, 2.25x or 4x, `maxSourceSeconds` 5), the three NVIDIA RTX Video models of `rtx-video.ts`, `oss-video-key-corridorkey` (CorridorKey 2.0 on `video-key-corridorkey`, `greenScreen`: the cut-out, its mask or the clean foreground, as WebM, ProRes 4444 or EXR), `oss-video-matte-vrmbg3` (Bria VRMBG 3.0 on `video-matte-vrmbg3`, gated weights placed by hand), `oss-matte-feynobg` (FeyNoBg fine hair on `image-matte-feynobg`), `oss-auk` (Tencent AuK: `speech-edit` on `speech-edit-auk`, `tts` on `speech-tts-auk`), `oss-idol-mesh` (Idol 3D quick mesh, `image-to-3d` on `image-to-mesh-idol`) and six hidden helpers: `oss-hi3d-refine` (`refine-3d` on `mesh-refine-hi3d`), `oss-hy-nomas-world` (`world-turn` on `world-hy-nomas-turn`), `oss-person-mask` (SAM 3.1, `bg-remove` on `image-person-mask-sam3`), and `oss-worldcast`, `oss-depth-pro` and `oss-vggt-omega`, whose routes go to the `worldcast` provider (endpoints `cases`, `depth/depth-pro`, `depth/vggt-omega`) and whose licences are in `ModelDef.licence`. `oss-minimax-h3` gains a `ref2v` and an `avatar` route on `minimax-h3-flex-ref2va` (Pika H3 Flex), the Quality value `flex` (the 6-step Flex graphs), `maxImages` 9, `maxVideos` 3 and `maxAudios` 3, and `finishTiers: ["2K"]` only while Regenerate is offered (`REGEN_OFFERED`, false). `oss-pixal3d`, `oss-trellis2`, `oss-hunyuan3d-21`, `oss-trellis2-multi` and `oss-idol-mesh` carry the "Refine detail · Hi3D 1.0" control (`params.extra.hi3dRefine`) |
+| `../auto-image.ts` | Auto (`oss-auto-image`), the Image studio's open default: a catalog entry whose routes are its picks' own (so the picker, the price and the GPU pre-flight read them), never run as itself. `autoCandidates` picks the model for a request (a picture to work from → the edit model for its operation; lettering → Ideogram 4; a line of the owner's `autoImagePatterns` setting → Krea 2 Realism; else Ideogram 4), and `src/server/generations.ts` `autoRouted` plans the first that is switched on and keeps the pick in `GenerationRequest.auto`, so a run planned again goes to the same model. When Ideogram 4 declines a run of Auto (every picture its grey card), `declinedAgain` makes it with `AUTO_FALLBACKS` (Krea 2 Realism, FIBO 2 Dev, MOSS-Image) in order, each only after the one before fails (`declinedFails`), on the same row, hold and admission. `autoLine` is the line the feed card, the run details, the Library and Accounts' runs show |
| `llm-models.ts` | `text-llm` (cloud: Claude, else a local model) and `oss-text-llm` (open: a local model only, never Claude, route endpoint `ollama`; since round 4 its translations run on ComfyUI's Qwen3.5 4B, `oss-qwen35-translate`, when no local model server is ready), kind `text`, ops `translate` and `write` |
| `elements.ts` | Elements (character / location / prop / style / voice), `@handle` parsing and `applyMentions`; since round 4 part 4 an element holds up to 80 photos (`MAX_ELEMENT_PHOTOS`) and a mention brings its trained LoRA to every model of the LoRA's family on either engine (`identityFor`); since round 4 part 5 an older Soul ID (the retired provider's `referenceId`) goes to no model; the element shows "Older Soul ID" with "Retrain for Fuobe Soul" (nothing retrains by itself) |
| `sketch.ts` | `applySketch` (masks and drawings → the right operation and inputs) |
diff --git a/docs/FEATURES.md b/docs/FEATURES.md
index 6fcd8cd3..b8f0a6fc 100644
--- a/docs/FEATURES.md
+++ b/docs/FEATURES.md
@@ -59,7 +59,8 @@ Fuobe is a complete creative studio you can run yourself: 108 camera motions, 25
- **Create:** Image · Video (text, image, start/end frame, **Frames**: up to 10 stills on a timeline, reference images and clips, multi-shot, draft mode) · Edit · **Layers** (split a flat image into editable layers, edit text with the lines found for you on either engine, Inpaint a painted area, an Enhancer (skin, soft glow, sharpen, detail), regional edits, save a layer as an element, cropped or positioned zips) · Inpaint & Draw to Edit · Color grading · Camera motions and Effects (on Fuobe DoP) · Storyboard (Popcorn: a board in one of Fuobe Soul's looks if you like, priced next to Generate, and turned into a film; cloud boards start on hosted open models, Z-Image Turbo or Qwen-Image-Edit, then Qwen-Image-Edit 2509 with a next-scene LoRA, and "Frames made on" switches them to Nano Banana Pro) · **Canvas** (wire prompts, files and models into node workflows; every template in a cloud and an open-source version, 10 Effects 2.0 chains among them (your photo, a "Set the scene" edit, then a 5 s Fuobe DoP clip); up to 20 pages per board, groups you can run as one, comment pins with replies, and drawing, shapes and text from a toolbar with keys; a Table node runs the node it feeds once per row; Change voice, Clone voice, Translate (text, or a dub of a video) and Video concatenator (cut, mute and join up to 50 clips) nodes) · Apps
- **Live edit** (Create → Live edit, the Edit studio's Live switch, a Library picture's "Change it as you type") — the picture changes as you type, on your own GPU: Qwen-Image 2.1 with linoyts' 2-step DMD2 LoRA on Fuobe's live nodes (fuobe_live.py, which the Windows start file and the setup card add to ComfyUI). Live frames come at 384 to 768 px (Auto steps down on a slower GPU); a pause renders the text on screen at full quality. One prompt keeps growing: Enter ends a change and starts the next, and every frame renders all the words on the original with one seed for the session, so the picture stays steady while you type and nothing wears down, however many changes you make. Undo drops the newest change; Start fresh makes the picture on screen the new original (a lossless full-size master) and clears the words. Hold C to compare (Shift+C with the original), paint a region to change only that. On "Use the ComfyUI on this computer" the tab talks to its ComfyUI directly. Guests see a recorded session. Non-commercial weights; none of it has rendered on a real GPU yet
- **MOSS-Image** (Image studio → model menu → MOSS-Image) — OpenMOSS's picture model, made for Chinese and English text in pictures. In the cloud it runs on fal at $0.05 per megapixel, up to 4 images (fal's safety checker returns a black image when it flags an output). On your GPU it is free, on ComfyUI's built-in nodes, with about 15 GB of files and 16 GB of VRAM (a guess); **Options → Quality** picks Standard (25 steps), Best (50), Fast (8 steps, an extra 5.4 GB file) or Base model (MOSS-Image Base, 50 steps, an extra 5.4 GB file). Its text encoder is the int8 Qwen3.5-9B: the w4a8 build in ComfyUI's template crashed the graphics driver on a test PC. The Image studio's controls chip now reads **Options** (it read "Director"). Text placed in boxes: the Image studio's Layout mode draws the boxes on the picture, and `src/lib/layout-prompt.ts` turns them into MOSS's prompt
-- **The newest open image models, first on your GPU** — Ideogram 4, Qwen-Image 2.1 and its Turbo, Krea 2 (Realism, Turbo, Edit, Identity Edit, Image to image, Inpaint) and FIBO 2 (Dev, Edit Turbo), from the owner's ComfyUI workflows. On the open engine the Image studio opens on Ideogram 4 (on Qwen-Image 2.1 for an account, a guest, or an install with no local LLM to write Ideogram's caption) and Edit and Inpaint on Qwen-Image 2.1; every model menu's "Best" list puts the new models first (text to image: Ideogram 4, Qwen-Image 2.1, Krea 2 Realism, MOSS-Image, then FIBO 2 Dev; edits: Qwen-Image 2.1, its Turbo, FIBO 2 Dev and Edit Turbo, then Krea 2 Edit), and so do apps, Layers, Canvas, Cinema stills, Photodump, Fashion Factory and Character swap's anchor. Apps and tools that run a LoRA trained on an older model keep it (Angles, Relight, Product shot, Try-On, Cinema's recompose). Ideogram 4 reads a JSON caption, which Fuobe writes from your words (with your local LLM, never a paid API; a plain caption without one) and keeps as the run's prompt. When Ideogram's safety filter sends its grey card instead of a picture, the run fails and says what to try. Soul Location doesn't offer Ideogram 4 (pictures of empty places hit that filter most), and a new Layers layer starts on Qwen-Image 2.1. Qwen-Image 2.1, FIBO 2 and Krea 2 Edit take up to 4 references (Krea 2 Edit 2) and leave out the ones you don't give; an edit keeps image 1's shape and size, so Edit and Inpaint show no aspect or size choice for them, and Qwen-Image 2.1's inpaint and expand take the picture alone. An app run made before an app moved to Qwen-Image 2.1 (a retry, Run again, Reuse) runs on Qwen-Image 2.1 and says so. About 92 GB of new files, 20–24 GB of VRAM (estimates), ComfyUI 0.42.0; Krea 2 runs Comfy-Org's fp8 Krea 2 Turbo, the file the owner's edit workflow loads. Krea 2 Inpaint also needs the ComfyUI-Krea2-Ostris-Edit node pack, so it isn't in Inpaint's "Best" list. Qwen-Image 2.1, Ideogram 4 and FIBO 2 weights are non-commercial. None of the 16 graphs has rendered through Fuobe yet
+- **The newest open image models, first on your GPU** — Ideogram 4, Qwen-Image 2.1 and its Turbo, Krea 2 (Realism, Turbo, Edit, Identity Edit, Image to image, Inpaint) and FIBO 2 (Dev, Edit Turbo), from the owner's ComfyUI workflows. On the open engine the Image studio opens on Auto (next item) and Edit and Inpaint on Qwen-Image 2.1; every model menu's "Best" list puts the new models first (text to image: Ideogram 4, Qwen-Image 2.1, Krea 2 Realism, MOSS-Image, then FIBO 2 Dev; edits: Qwen-Image 2.1, its Turbo, FIBO 2 Dev and Edit Turbo, then Krea 2 Edit), and so do apps, Layers, Canvas, Cinema stills, Photodump, Fashion Factory and Character swap's anchor. Apps and tools that run a LoRA trained on an older model keep it (Angles, Relight, Product shot, Try-On, Cinema's recompose). Ideogram 4 reads a JSON caption, which Fuobe writes from your words (with your local LLM, never a paid API; a plain caption without one) and keeps as the run's prompt. When Ideogram's safety filter sends its grey card for every picture of a run, the run is made once more with a new seed, then with Qwen-Image 2.1, before it fails and says what to try; the card is kept for the owner to look at. Soul Location doesn't offer Ideogram 4 (pictures of empty places hit that filter most), and a new Layers layer starts on Qwen-Image 2.1. Qwen-Image 2.1, FIBO 2 and Krea 2 Edit take up to 4 references (Krea 2 Edit 2) and leave out the ones you don't give; an edit keeps image 1's shape and size, so Edit and Inpaint show no aspect or size choice for them, and Qwen-Image 2.1's inpaint and expand take the picture alone. An app run made before an app moved to Qwen-Image 2.1 (a retry, Run again, Reuse) runs on Qwen-Image 2.1 and says so. About 92 GB of new files, 20–24 GB of VRAM (estimates), ComfyUI 0.42.0; Krea 2 runs Comfy-Org's fp8 Krea 2 Turbo, the file the owner's edit workflow loads. Krea 2 Inpaint also needs the ComfyUI-Krea2-Ostris-Edit node pack, so it isn't in Inpaint's "Best" list. Qwen-Image 2.1, Ideogram 4 and FIBO 2 weights are non-commercial. None of the 16 graphs has rendered through Fuobe yet
+- **Auto, the Image studio's first pick on your GPU** — Auto picks the open model for each run, for everyone (the owner, accounts, and a guest's draft): a run with a picture to work from goes to the edit model for its operation (Qwen-Image 2.1), lettering, posters, logos and signs to Ideogram 4, prompts that Ideogram 4's safety filter often declines to Krea 2 Realism, and everything else to Ideogram 4. Those prompts are a list the owner edits in Settings → Auto image model (one word, phrase or pattern per line; a built-in list to start with). When Ideogram 4 declines a run of Auto, Krea 2 Realism, then FIBO 2 Dev, then MOSS-Image make the same run, each only if the one before fails; it is still one run for limits and billing. The tile, the run details and the Library say what made it ("Auto · made with Krea 2 Realism · Ideogram 4 declined this one"), and the price before Run is the picked model's. Picking a model by name always runs that model. On a declined run the owner also sees the words it declined and "Add a pattern", which puts a line on that list
- **Kandinsky 6.0** (Video studio → model menu, both engines) — Kandinsky Lab's model makes 5 s clips at 480p with sound and lip-synced dialogue, from words or a first frame. Words in quotes are what someone says, and a closing `Sound:` line sets the sound. On your GPU it is free, on Kandinsky Lab's own node packs: **Options → Quality** picks Lite (10 steps, the default; about 24 GB of VRAM, an estimate) or Pro (about 80 GB, with an extra 60 GB file), and the Prompt helper (an extra 19 GB file) writes a fuller caption first. In the cloud it runs on fal: Pro or Lite at Fast, Standard or Best steps (Pro · Standard, the default, $0.56 a clip; Lite from $0.08; Pro · Best $1.35). Lipsync & avatars links a talking character from words to the Video studio on Kandinsky. **Kandinsky VSR** (Upscale → Video, both engines) upscales clips up to 5 s by 2x, 2.25x (the default, 480p to 1080p) or 4x, about $0.09 for 5 s of 480p to 1080p on fal
- **Pika H3 Flex** (your GPU only) — Pika's add-on that makes MiniMax H3 clips in 6 steps. In the Video studio, MiniMax H3's Quality offers **Fast · Pika Flex (6 steps)** for words and first and last frames, and a **References** chip takes up to 9 images, 3 clips and 3 voice or music clips (Image N, Clip N and Voice N in the prompt). Cinema's reference takes and "Talk from a voice clip" in Lipsync & avatars use it too. 32 GB of VRAM recorded, not measured. No hosted service offers the add-on, so the cloud keeps hosted MiniMax H3 under its own name. MiniMax H3's other choices now read "Standard · 8 steps" and "Sharper · 20 steps"
- **One sheet** (Storyboard) and **Re-render from layers** (Layers) — One sheet draws up to 8 panels on one picture with MOSS-Image (your GPU or fal), then cuts it into frames, each with Animate and Edit; it stays the owner's until a GPU test is recorded. Re-render from layers (desktop) repaints the layers as one picture, which lands as a new top layer: MOSS-Image on both engines, Ideogram 4.5 and FLUX.3 in the cloud
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 7fa19068..676332fc 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -88,7 +88,7 @@ Model names are the defaults first, then the alternatives. "Demo" outputs are la
| Feature | Fuobe | Cloud route | Open-source route | Notes |
|---|---|---|---|---|
-| Create Image (multi-model) | 🟢 | 68 cloud image models in the catalog (editing and cut-out tools included): Nano Banana Pro / 2 / 2.1, Seedream 5.0 Pro / Flash / Lite, GPT Image 2.5 Flare / Sunburst, FLUX.3, FLUX.2 [pro], Kontext [max], Ideogram 4.5 / 3.0, Recraft V4.1 / Pro, Qwen Image 3, Wan 2.7 Image, Z-Image Turbo, Imagen 4, Grok Imagine Image 2.0, Krea 3, Bria FIBO 2, Ideogram Vector, MOSS-Image (row below), and hosted open-weight models that take LoRAs: Qwen-Image 2512, Qwen-Image-Edit 2511, FLUX.2 [klein] 4B, Wan 2.2 A14B Image, and (new for Soul ID) FLUX.1 [dev], FLUX.1 Krea [dev], FLUX.2 [dev], FLUX.2 [klein] 9B and Krea 2 Turbo, each with its licence in its tagline | Ideogram 4 (Qwen-Image 2.1 for an account, a guest, or with no local LLM to write Ideogram's caption), Qwen-Image 2.1, Krea 2 Realism / Turbo, MOSS-Image, FIBO 2 Dev, Z-Image Turbo, Qwen-Image 2512 (+ Lightning), FLUX.2 [dev] (+ Turbo), FLUX.1 Krea / dev / schnell, HiDream, SDXL | Batch ×1–4, aspect ratios, quality tiers, seeds, negative prompts, references. The Image studio lists text-to-image models only; edit tools live in Edit. Fuobe Soul, Soul HD and Soul Cinema (both engines, next rows) are listed first. On the open engine a `?model=` link now keeps the linked model (it used to land on Z-Image Turbo). Per-megapixel cloud prices now count every picture asked for. Grok Imagine Image 2.0 takes up to 5 references (fal's edit limit; it took 10 through the retired provider) |
+| Create Image (multi-model) | 🟢 | 68 cloud image models in the catalog (editing and cut-out tools included): Nano Banana Pro / 2 / 2.1, Seedream 5.0 Pro / Flash / Lite, GPT Image 2.5 Flare / Sunburst, FLUX.3, FLUX.2 [pro], Kontext [max], Ideogram 4.5 / 3.0, Recraft V4.1 / Pro, Qwen Image 3, Wan 2.7 Image, Z-Image Turbo, Imagen 4, Grok Imagine Image 2.0, Krea 3, Bria FIBO 2, Ideogram Vector, MOSS-Image (row below), and hosted open-weight models that take LoRAs: Qwen-Image 2512, Qwen-Image-Edit 2511, FLUX.2 [klein] 4B, Wan 2.2 A14B Image, and (new for Soul ID) FLUX.1 [dev], FLUX.1 Krea [dev], FLUX.2 [dev], FLUX.2 [klein] 9B and Krea 2 Turbo, each with its licence in its tagline | Auto (the default: Ideogram 4 for most and for lettering, Krea 2 Realism for prompts Ideogram 4's filter often declines, Qwen-Image 2.1 for edits; Krea 2 Realism, FIBO 2 Dev, then MOSS-Image when Ideogram 4 declines a run), Ideogram 4, Qwen-Image 2.1, Krea 2 Realism / Turbo, MOSS-Image, FIBO 2 Dev, Z-Image Turbo, Qwen-Image 2512 (+ Lightning), FLUX.2 [dev] (+ Turbo), FLUX.1 Krea / dev / schnell, HiDream, SDXL | Batch ×1–4, aspect ratios, quality tiers, seeds, negative prompts, references. The Image studio lists text-to-image models only; edit tools live in Edit. Fuobe Soul, Soul HD and Soul Cinema (both engines, next rows) are listed first. On the open engine a `?model=` link now keeps the linked model (it used to land on Z-Image Turbo). Per-megapixel cloud prices now count every picture asked for. Grok Imagine Image 2.0 takes up to 5 references (fal's edit limit; it took 10 through the retired provider) |
| Text in pictures with MOSS-Image (Fuobe's own: N7-1) | 🟢 cloud · 🟢 open | MOSS-Image on fal: $0.05 per megapixel, up to 4 images; with LoRAs (up to 3) its LoRA endpoint, at a price the app shows as unknown. fal's safety checker returns a black image when it flags an output | `moss-image-t2i` on built-in nodes only: Options → Quality is Standard (25 steps), Best (50), Fast (8, an extra 5.4 GB file) or Base model (MOSS-Image Base, 50 steps, an extra 5.4 GB file); free, about 15 GB of files with the int8 Qwen3.5-9B encoder (the template's w4a8 one crashed a test PC's graphics driver), 16 GB of VRAM (a guess) | Image studio → model menu → MOSS-Image: OpenMOSS's picture model, made for Chinese and English text in pictures. The Image studio's Layout mode (N7-2, built on `main`) draws layout boxes (where each piece of text goes), and `src/lib/layout-prompt.ts` turns them into MOSS's prompt. Settings → Models & licences has a row and a switch for each engine's MOSS-Image. **Public sign-up:** guests see the price and are asked to sign up to run it; accounts can run the open MOSS-Image on their own ComfyUI, the only new tool of round 5, part 2 they can run. Checked: fal payloads against its schema, prices and bindings in unit tests, the graph accepted by a CPU ComfyUI, the menu and Options in the browser (`moss-image.mjs`: in full on its package branch; 10 failures in PR #15's run, §1). Nothing has rendered on fal or a GPU, so the lettering is unjudged |
| Soul 2.0 / Soul v1 (139 looks) → Fuobe Soul and Fuobe Soul HD | 🟢 cloud · 🟢 open | Fuobe Soul: Z-Image Turbo on fal (its LoRA endpoint when the look has LoRAs, its image-to-image endpoint for a picture), Replicate's Z-Image Turbo for text to image: $0.005 a megapixel, $0.0085 with LoRAs (the default General look has LoRAs). Fuobe Soul HD: Qwen-Image 2512 on fal, $0.02 a megapixel, $0.035 with LoRAs. No retired provider's call: Soul 2.0 and Soul v1 themselves are retired (O7), and a stored or linked run on them (`/image?model=soul-2`, Reuse, the API) opens on Fuobe Soul, its Soul style becoming the matching Fuobe look | Fuobe Soul: Z-Image Turbo with up to 3 of the look's LoRAs; image to image on the new `z-image-turbo-i2i` (~12 GB VRAM, no new download). Fuobe Soul HD: Qwen-Image 2512 | Image studio → Look chip on Fuobe Soul and Soul HD: 139 looks in two sets named after the parity studio's versions, Soul 2.0 (33) and Soul (106), with categories, search, drawn covers and a Strength slider. 87 looks use civitai LoRAs and are marked; without a civitai key a run leaves those out and says so. Attach a picture and the look restyles it (how much is fixed: 0.6 on the GPU, fal's default in the cloud). Soul HD is for lettering; the Graffiti look moves a run there. In a studio feed the browser finishes each result (crop, grade, overlays such as DigitalCam's date stamp) and saves it, keeping the raw picture. Also in ⌘K, `/models`, Canvas (General look only), Assist and the CLI (`--look`, `--look-strength`, `--engine`). The empty Image studio's **Make your own Soul look** cards show on Fuobe Soul and Soul HD (only Soul 2.0 had them). **PixeletedFace** (round 5, part 1) now really pixelates faces: each picture is followed by a **Face mosaic** step that finds the faces with SAM 3.1 (fal's SAM 3.1 image, +$0.01 a picture in the cloud; the new `image-face-mosaic-sam3` graph, free on your GPU, 4 GB) and lays blocks of about 25 px over them, priced in the composer; the unpixelated picture stays in the Library as the "Before the face mosaic" step (it only asked for pixelation in words before). It also works in pipeline steps and Canvas nodes. Checked in demo mode (`open-tools.mjs`: the cloud price goes from $0.009 to $0.018 with the step); no look's picture has been seen (no GPU, no key) |
| Soul Cinema → Fuobe Soul Cinema | 🟢 cloud · 🟢 open | Z-Image Turbo on fal (Replicate for text to image) with the film-still LoRAs, priced as Fuobe Soul. The earlier Soul Cinema is retired; a stored run on it opens on Fuobe Soul Cinema | Z-Image Turbo with the film-still LoRAs | One fixed film look (filmstill 0.7 + moviewide 0.5 and a teal-orange grade) and a 21:9 shape, made at 16:9 and cropped in the browser. A look picked for it is described in words. moviewide is a civitai LoRA, so without a key the cloud runs filmstill only. A 21:9 demo run was cropped with its grade in the browser check. It is now Cinema Studio's still model on both engines, and the Cinema feed finishes it too (`cinema-original.mjs`) |
diff --git a/src/components/account-runs.tsx b/src/components/account-runs.tsx
index c26f4b72..4bd7ee9a 100644
--- a/src/components/account-runs.tsx
+++ b/src/components/account-runs.tsx
@@ -10,6 +10,7 @@ import { StatusCover } from "@/components/library/asset-card";
import { PageHeader } from "@/components/page-shell";
import { GallerySkeleton } from "@/components/skeletons";
import { DeclinedCards } from "@/components/studio/made-note";
+import { autoLine } from "@/lib/auto-image";
import { MediaThumb } from "@/components/studio/result-media";
import { Button } from "@/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
@@ -435,6 +436,7 @@ function RunWords({ g }: { g: AdminRun }) {
<div className="text-[12px]">
{prompt ? <p className={cn("break-words", open ? "whitespace-pre-wrap" : "line-clamp-2")}>{prompt}</p> : <p className="text-muted-foreground italic">No prompt</p>}
{open && error && <p className="mt-1 break-words whitespace-pre-wrap text-destructive">{error}</p>}
+ {autoLine(g) && <p className="mt-1 break-words text-muted-foreground">{autoLine(g)}</p>}
{g.request.notice && <p className="mt-1 break-words text-muted-foreground">{g.request.notice}</p>}
{!!g.declinedCards?.length && <DeclinedCards cards={g.declinedCards} className="mt-1 block break-words text-muted-foreground" />}
{((prompt?.length ?? 0) > 120 || error) && (
diff --git a/src/components/add-auto-pattern.tsx b/src/components/add-auto-pattern.tsx
new file mode 100644
index 00000000..04d2d901
--- /dev/null
+++ b/src/components/add-auto-pattern.tsx
@@ -0,0 +1,92 @@
+"use client";
+
+import { useState } from "react";
+import { toast } from "sonner";
+import { autoPatternsProblems } from "@/lib/auto-image";
+import { cn } from "@/lib/utils";
+
+/**
+ * Settings → Auto image model's list, one line added: the setting as saved, with `line` after it. Already there: null.
+ * Throws the problem when the line can't be a pattern.
+ */
+export function withAutoPattern(saved: string, line: string): string | null {
+ const add = line.trim();
+ const problem = autoPatternsProblems(add)[0];
+ if (!add || problem) throw new Error(problem?.replace(/^Line 1 /, "It ") ?? "Type a word or a pattern first");
+ const lines = saved.split(/\r?\n/).map((l) => l.trim());
+ if (lines.includes(add)) return null;
+ return [...lines.filter((l, i) => l || i < lines.length - 1), add].join("\n");
+}
+
+/**
+ * The owner's "Add a pattern" on a run Ideogram 4 declined: a word, phrase or pattern (the words selected on the page, to
+ * start with) goes on Auto's list in Settings, so Auto sends such prompts to Krea 2 Realism next time. Owner only: the
+ * settings it changes are the owner's (an account gets a 403).
+ */
+export function AddAutoPattern({ className }: { className?: string }) {
+ const [line, setLine] = useState<string | null>(null);
+ const [busy, setBusy] = useState(false);
+ const add = async () => {
+ if (line === null) return;
+ setBusy(true);
+ try {
+ const got = (await (await fetch("/api/settings")).json()) as { settings?: { name: string; value: string }[] };
+ const saved = got.settings?.find((s) => s.name === "autoImagePatterns")?.value ?? "";
+ const next = withAutoPattern(saved, line);
+ if (next === null) {
+ toast.message("That pattern is on the list already");
+ setLine(null);
+ return;
+ }
+ const res = await fetch("/api/settings", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ autoImagePatterns: next }) });
+ const body = (await res.json().catch(() => ({}))) as { error?: string };
+ if (!res.ok || body.error) throw new Error(body.error ?? "Couldn't save the pattern");
+ toast.success("Added: Auto sends prompts like this to Krea 2 Realism");
+ setLine(null);
+ } catch (e) {
+ toast.error((e as Error).message);
+ } finally {
+ setBusy(false);
+ }
+ };
+ if (line === null) {
+ return (
+ <button
+ type="button"
+ data-add-auto-pattern
+ className={cn("ml-1 underline underline-offset-2 hover:text-foreground", className)}
+ onClick={() => {
+ // The words selected on the page, when there are a few, start the pattern.
+ const picked = typeof window !== "undefined" ? (window.getSelection()?.toString().trim() ?? "") : "";
+ setLine(picked.length <= 80 ? picked : "");
+ }}
+ >
+ Add a pattern
+ </button>
+ );
+ }
+ return (
+ <span className={cn("mt-1 flex items-center gap-1.5", className)}>
+ <input
+ autoFocus
+ aria-label="Pattern for Auto"
+ value={line}
+ placeholder="a word, phrase or pattern"
+ maxLength={300}
+ disabled={busy}
+ onChange={(e) => setLine(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") void add();
+ if (e.key === "Escape") setLine(null);
+ }}
+ className="h-7 min-w-0 flex-1 rounded-md border bg-background px-2 text-[12px] text-foreground"
+ />
+ <button type="button" disabled={busy || !line.trim()} onClick={() => void add()} className="rounded-md border px-2 py-0.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:opacity-50">
+ Add
+ </button>
+ <button type="button" disabled={busy} onClick={() => setLine(null)} className="px-1 text-[12px] hover:text-foreground">
+ Cancel
+ </button>
+ </span>
+ );
+}
diff --git a/src/components/auto-patterns-setting.tsx b/src/components/auto-patterns-setting.tsx
new file mode 100644
index 00000000..88e3cf3b
--- /dev/null
+++ b/src/components/auto-patterns-setting.tsx
@@ -0,0 +1,59 @@
+"use client";
+
+import { useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import type { PublicSetting } from "@/components/connect-field";
+import { autoPatternsProblems, DEFAULT_AUTO_PATTERNS } from "@/lib/auto-image";
+
+/**
+ * Settings → Auto image model: the prompts Auto sends to Krea 2 Realism straight away (Ideogram 4's safety filter often
+ * declines them), one per line. The owner's only, as every setting is. Saving checks each line; Reset puts the built-in
+ * list back.
+ */
+export function AutoPatternsSetting({ setting, onSave, saving }: { setting: PublicSetting | undefined; onSave: (value: string) => void; saving: boolean }) {
+ const saved = setting?.value ?? DEFAULT_AUTO_PATTERNS.join("\n");
+ const [text, setText] = useState(saved);
+ // A save (here, or Add a pattern on a run) changes what is saved: the box follows it.
+ const [shown, setShown] = useState(saved);
+ if (shown !== saved) {
+ setShown(saved);
+ setText(saved);
+ }
+ const problems = autoPatternsProblems(text);
+ const changed = text.trim() !== saved.trim();
+ return (
+ <div className="space-y-2">
+ <Label htmlFor="setting-auto-patterns" className="text-[13px] font-medium">
+ Prompts that go to Krea 2 Realism
+ </Label>
+ <textarea
+ id="setting-auto-patterns"
+ value={text}
+ spellCheck={false}
+ rows={10}
+ onChange={(e) => setText(e.target.value)}
+ className="block w-full resize-y rounded-xl border bg-background p-3 font-mono text-[12px] leading-relaxed"
+ />
+ <p className="text-[12px] leading-relaxed text-muted-foreground">
+ One per line. A word or phrase matches as a whole word (a space or a hyphen matches either); any other line is a regular expression. Case
+ doesn&rsquo;t matter, and a line that starts with # is a note. Prompts about lettering, posters or logos still go to Ideogram 4.
+ </p>
+ {problems.length > 0 && (
+ <ul className="space-y-0.5 text-[12px] text-destructive">
+ {problems.slice(0, 5).map((p) => (
+ <li key={p}>{p}</li>
+ ))}
+ </ul>
+ )}
+ <div className="flex gap-2">
+ <Button size="sm" disabled={!changed || problems.length > 0 || saving} onClick={() => onSave(text)}>
+ Save
+ </Button>
+ <Button size="sm" variant="outline" disabled={saving || !setting?.isSet} onClick={() => onSave("")}>
+ Reset to the built-in list
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/library/asset-card.tsx b/src/components/library/asset-card.tsx
index 58238edb..f401aff9 100644
--- a/src/components/library/asset-card.tsx
+++ b/src/components/library/asset-card.tsx
@@ -17,6 +17,7 @@ import { TroubleActions, TroubleDetails } from "@/components/gpu/trouble";
import { RunTroubleActions } from "@/components/gpu/run-trouble-actions";
import { DRAG_TYPE } from "./folders";
import { ReviewBadge } from "./review";
+import { autoLine } from "@/lib/auto-image";
import type { Layout } from "./view-options";
/** Stable callbacks from the Library (refs inside), so cards re-render only when their own data changes. */
@@ -297,7 +298,8 @@ 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 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 Qwen-Image 2.1 · 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). */}
{!stack && !trashed && (g.status === "failed" ? g.trouble : g.status === "queued" ? g.waiting : undefined) && (
diff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsx
index a3615bc5..ce93c1f8 100644
--- a/src/components/settings-form.tsx
+++ b/src/components/settings-form.tsx
@@ -30,6 +30,7 @@ import { ConnectorSettings } from "@/components/assist/connectors-settings";
import { NotificationSettings } from "@/components/notification-settings";
import { SecuritySettings } from "@/components/security-settings";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
+import { AutoPatternsSetting } from "@/components/auto-patterns-setting";
function Section({
id,
@@ -763,6 +764,15 @@ export function SettingsForm({ prices }: { prices?: string }) {
</label>
</Section>
+ <Section
+ id="auto-image"
+ title="Auto image model"
+ description="Auto is the Image studio's first pick on the open engine: Ideogram 4 for most pictures and for lettering, Qwen-Image 2.1 for edits, and Krea 2 Realism for the prompts below, which Ideogram 4's safety filter often declines. When Ideogram 4 declines a run anyway, Krea 2 Realism, FIBO 2 Dev, then MOSS-Image make it."
+ inactive={mode === "cloud" ? "Not used in Paid APIs only mode" : undefined}
+ >
+ <AutoPatternsSetting setting={get("autoImagePatterns")} saving={save.isPending} onSave={set("autoImagePatterns")} />
+ </Section>
+
<Section
id="models"
title="Models & licences"
diff --git a/src/components/studio/made-note.tsx b/src/components/studio/made-note.tsx
index 056b416c..061452b9 100644
--- a/src/components/studio/made-note.tsx
+++ b/src/components/studio/made-note.tsx
@@ -1,26 +1,35 @@
import { changeLine } from "@/lib/catalog/made";
import type { Generation } from "@/lib/catalog/types";
+import { autoLine } from "@/lib/auto-image";
+import { AddAutoPattern } from "@/components/add-auto-pattern";
import { cn } from "@/lib/utils";
+type NoteRun = Pick<Generation, "made" | "declinedCards" | "status" | "modelId" | "modelName"> & {
+ request: Pick<Generation["request"], "notice" | "modelId" | "auto" | "prompt">;
+};
+
/**
* Under a run (the feed card, the run details): each setting it was made at differently from what it asked, in one small
- * muted line ("Quality: asked for 2K · made at 1080p (the most this model makes)"), what changed while it ran (its
- * notice: "Made with Qwen-Image 2.1 · Ideogram 4 declined this one"), and, for the owner's eyes only, what Ideogram 4
- * returned in place of a picture. Nothing when it made what it asked.
+ * muted line ("Quality: asked for 2K · made at 1080p (the most this model makes)"), 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 ·
+ * Ideogram 4 declined this one"), and, for the owner's eyes only, what Ideogram 4 returned in place of a picture, for
+ * which words. Nothing when it made what it asked.
*/
-export function MadeNote({ g, className }: { g: Pick<Generation, "made" | "declinedCards"> & { request: Pick<Generation["request"], "notice"> }; className?: string }) {
+export function MadeNote({ g, className }: { g: NoteRun; className?: string }) {
const changes = g.made?.changes ?? [];
+ const auto = autoLine(g);
const notice = g.request.notice?.trim();
- if (!changes.length && !notice && !g.declinedCards?.length) return null;
+ if (!changes.length && !auto && !notice && !g.declinedCards?.length) return null;
return (
<ul className={cn("space-y-0.5 text-[11.5px] leading-snug text-pretty text-muted-foreground", className)} aria-label="Made differently from what was asked">
{changes.map((c) => (
<li key={c.setting + c.label}>{changeLine(c)}</li>
))}
+ {auto && <li>{auto}</li>}
{notice && <li>{notice}</li>}
{!!g.declinedCards?.length && (
<li>
- <DeclinedCards cards={g.declinedCards} />
+ <DeclinedCards cards={g.declinedCards} words={g.request.prompt} />
</li>
)}
</ul>
@@ -29,9 +38,12 @@ export function MadeNote({ g, className }: { g: Pick<Generation, "made" | "decli
/**
* The owner's line on a run Ideogram 4 declined: a link to each picture it returned in place of one, with the two
- * measures that took it for the "blocked" card, so a false catch can be told from the card.
+ * measures that took it for the "blocked" card, so a false catch can be told from the card; the words it declined
+ * (`words`, where the view doesn't show them already); and "Add a pattern", which sends such words to Krea 2 Realism
+ * next time Auto picks (Settings → Auto image model).
*/
-export function DeclinedCards({ cards, className }: { cards: NonNullable<Generation["declinedCards"]>; className?: string }) {
+export function DeclinedCards({ cards, words, className }: { cards: NonNullable<Generation["declinedCards"]>; words?: string; className?: string }) {
+ const said = words?.trim();
return (
<span className={className}>
Ideogram 4 declined: what it returned{" "}
@@ -44,6 +56,8 @@ export function DeclinedCards({ cards, className }: { cards: NonNullable<Generat
(colour spread {c.spread}, {Math.round(c.grey * 100)}% grey)
</span>
))}
+ {said && <span className="block break-words">Words: “{said.length > 400 ? `${said.slice(0, 400)}…` : said}”</span>}
+ <AddAutoPattern />
</span>
);
}
diff --git a/src/lib/auto-image.ts b/src/lib/auto-image.ts
new file mode 100644
index 00000000..ad719634
--- /dev/null
+++ b/src/lib/auto-image.ts
@@ -0,0 +1,162 @@
+import type { AutoPick, AutoWhy, Operation } from "./catalog/types";
+
+/*
+ * Auto: the open image choice that picks the model for each run (the Image studio's default on the open engine). It is
+ * a choice, not a model of its own: the server plans the run on the model it picks (src/server/generations.ts autoRouted)
+ * and keeps the pick with the run (GenerationRequest.auto), so the run, its tile and the Library say which model made it.
+ * Pure and browser-safe: the composer, the Settings page and the server read the same rules.
+ */
+
+/** Auto's id in the catalog (src/lib/catalog/models.ts). */
+export const AUTO_IMAGE = "oss-auto-image";
+export const AUTO_NAME = "Auto";
+
+/** Words, posters, logos and everything without a reason to go elsewhere. */
+export const AUTO_TEXT_MODEL = "oss-ideogram-4";
+/**
+ * When Ideogram 4 declines a run (its grey "blocked" card for every picture), the same run is made by these, in order,
+ * each only if the one before fails. A prompt that matches a pattern of the setting starts with the first of them.
+ */
+export const AUTO_FALLBACKS = ["oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"] as const;
+/**
+ * A run with a picture to work from goes to the studio's own default for its operation (the Edit and Inpaint studios'
+ * Qwen-Image 2.1), never to Ideogram 4. FIBO 2 Dev, which also edits, is next where Qwen-Image 2.1 is switched off.
+ */
+export const AUTO_EDIT_MODELS: Readonly<Partial<Record<Operation, readonly string[]>>> = {
+ edit: ["oss-qwen-image-21", "oss-fibo2-dev"],
+ inpaint: ["oss-qwen-image-21"],
+ outpaint: ["oss-qwen-image-21"],
+};
+
+/** Every model Auto may plan a run on (a stored pick names one of these, or it is planned again). */
+export const AUTO_MODELS: ReadonlySet<string> = new Set([AUTO_TEXT_MODEL, ...AUTO_FALLBACKS, ...Object.values(AUTO_EDIT_MODELS).flat()]);
+
+/**
+ * Prompts about lettering: what Ideogram 4 is made for. Words in quotes count too ("a sign that says “OPEN”").
+ */
+const TEXT_WORDS =
+ /\b(text|texts|typography|typographic|typeface|font|fonts|lettering|letters|logo|logos|logotype|wordmark|monogram|poster|posters|signage|signs?|billboard|banner|headline|caption|calligraphy|graffiti|label|labels|menu|book cover|album cover|magazine cover|infographic|says|that reads)\b/i;
+const QUOTED = /["“”«»][^"“”«»\n]{2,80}["“”«»]/;
+
+/**
+ * The setting's first list (Settings → Auto image model): prompts that Ideogram 4's own safety filter often answers with
+ * its grey card. Auto sends them to Krea 2 Realism straight away. One per line: a word or phrase matches as a whole word
+ * (a space or a hyphen matches either), any other line is a regular expression, and a line that starts with "#" is a
+ * note; case never matters.
+ */
+export const DEFAULT_AUTO_PATTERNS: readonly string[] = [
+ "# Animals or creatures dressed as people",
+ String.raw`\b(cats?|kittens?|dogs?|pupp(y|ies)|fox(es)?|bunn(y|ies)|rabbits?|bears?|wol(f|ves)|lions?|tigers?|pandas?|owls?|monkeys?|horses?|deer|mice|mouse|creatures?|animals?)\b.{0,80}\b(gowns?|dress(es)?|suits?|tuxedos?|lingerie|bikinis?|heels|corsets?|skirts?|blouses?)\b`,
+ String.raw`\b(gowns?|dress(es)?|suits?|tuxedos?|lingerie|bikinis?|heels|corsets?)\b.{0,80}\b(cats?|kittens?|dogs?|pupp(y|ies)|fox(es)?|bunn(y|ies)|rabbits?|bears?|wol(f|ves)|lions?|tigers?|pandas?|owls?|monkeys?|creatures?|animals?)\b`,
+ String.raw`\b(cats?|kittens?|dogs?|pupp(y|ies)|fox(es)?|bunn(y|ies)|rabbits?|bears?|wol(f|ves)|lions?|tigers?|pandas?|owls?|monkeys?|creatures?|animals?)\b.{0,160}\b(her|his) (hair|body|legs|figure|curves|skin)\b`,
+ "# Swimwear, underwear and sheer clothes",
+ "swimwear",
+ "swimsuit",
+ "bikini",
+ "lingerie",
+ "underwear",
+ "bodysuit",
+ "sheer",
+ "see-through",
+ "topless",
+ "nude-tone",
+];
+
+/** The setting's limits: lines, and characters a line. */
+export const AUTO_PATTERNS_MAX = { lines: 200, chars: 300 };
+
+/** A line that is a word or phrase (matched as a whole word), not a regular expression. */
+const PLAIN = /^[\p{L}\p{N}][\p{L}\p{N}' -]*$/u;
+
+/** One line of the setting as a pattern (case-insensitive). Null: a blank line or a comment ("# …"). Throws on a bad one. */
+function lineRegExp(line: string): RegExp | null {
+ const s = line.trim();
+ if (!s || s.startsWith("#")) return null;
+ // A space or a hyphen matches either ("see-through", "see through"); an apostrophe either kind.
+ if (PLAIN.test(s)) return new RegExp(`(?<![\\p{L}\\p{N}])${s.split(/[-\s]+/).join("[-\\s]+").replace(/'/g, "['’]")}(?![\\p{L}\\p{N}])`, "iu");
+ return new RegExp(s, "i");
+}
+
+/**
+ * Why the setting's text can't be saved, one line per problem (empty: it can). Each line must be a pattern that can be
+ * read, can't match empty words (it would send every prompt to Krea 2 Realism), and stays within the limits.
+ */
+export function autoPatternsProblems(text: string): string[] {
+ const lines = text.split(/\r?\n/);
+ const problems: string[] = [];
+ if (lines.length > AUTO_PATTERNS_MAX.lines) problems.push(`Keep it to ${AUTO_PATTERNS_MAX.lines} lines`);
+ lines.forEach((line, i) => {
+ if (line.length > AUTO_PATTERNS_MAX.chars) return void problems.push(`Line ${i + 1} is over ${AUTO_PATTERNS_MAX.chars} characters`);
+ let re: RegExp | null;
+ try {
+ re = lineRegExp(line);
+ } catch {
+ return void problems.push(`Line ${i + 1} isn't a pattern that can be read: ${line.trim().slice(0, 60)}`);
+ }
+ if (re && re.test("")) problems.push(`Line ${i + 1} matches every prompt: ${line.trim().slice(0, 60)}`);
+ });
+ return problems;
+}
+
+/** The setting's text as patterns (lines that can't be read are left out, as saving refuses them). */
+export function autoPatterns(text: string): { line: string; re: RegExp }[] {
+ return text.split(/\r?\n/).flatMap((line) => {
+ try {
+ const re = lineRegExp(line);
+ return re && !re.test("") ? [{ line: line.trim(), re }] : [];
+ } catch {
+ return [];
+ }
+ });
+}
+
+/** The first line of the setting a prompt matches, or undefined. */
+export function matchedPattern(prompt: string, patterns: readonly { line: string; re: RegExp }[]): string | undefined {
+ return patterns.find((p) => p.re.test(prompt))?.line;
+}
+
+/** Is this prompt about lettering (posters, logos, signs, typography, words in quotes)? */
+export const asksForText = (prompt: string): boolean => TEXT_WORDS.test(prompt) || QUOTED.test(prompt);
+
+export interface AutoAsk {
+ prompt?: string;
+ op?: Operation;
+ /** Pictures the run works from (its references). */
+ images?: number;
+}
+
+/**
+ * The models Auto would plan a run on, best first, and why: a picture to work from → the studio's edit model for its
+ * operation; lettering → Ideogram 4; a prompt the setting's patterns match → Krea 2 Realism (then FIBO 2 Dev and
+ * MOSS-Image, then Ideogram 4); anything else → Ideogram 4 (then the others). The server plans the first one that is
+ * switched on and runs the operation (src/server/generations.ts autoRouted).
+ */
+export function autoCandidates(ask: AutoAsk, patterns: readonly { line: string; re: RegExp }[]): { models: string[]; why: AutoWhy; pattern?: string } {
+ const op = ask.op && ask.op !== "t2i" ? ask.op : (ask.images ?? 0) > 0 ? "edit" : "t2i";
+ if (op !== "t2i") return { models: [...(AUTO_EDIT_MODELS[op] ?? [])], why: "edit" };
+ const words = ask.prompt ?? "";
+ if (asksForText(words)) return { models: [AUTO_TEXT_MODEL, ...AUTO_FALLBACKS], why: "text" };
+ const pattern = matchedPattern(words, patterns);
+ if (pattern) return { models: [...AUTO_FALLBACKS, AUTO_TEXT_MODEL], why: "trigger", pattern };
+ return { models: [AUTO_TEXT_MODEL, ...AUTO_FALLBACKS], why: "plain" };
+}
+
+/** The model that makes an Auto run after `after` failed on one Ideogram 4 declined (undefined: none left). */
+export function nextAutoFallback(after: string | undefined): string | undefined {
+ const i = after ? (AUTO_FALLBACKS as readonly string[]).indexOf(after) : -1;
+ return AUTO_FALLBACKS[i + 1];
+}
+
+/** "Ideogram 4 declined this one", after the model that made a run in its place. */
+export const AUTO_DECLINED = "Ideogram 4 declined this one";
+
+/**
+ * The line under an Auto run (the feed card, the run details, the Library, Accounts' runs): "Auto · made with Ideogram 4",
+ * and "· Ideogram 4 declined this one" when another model made it in its place. Null for any other run.
+ */
+export function autoLine(g: { status: string; modelName?: string; modelId: string; request: { modelId: string; auto?: AutoPick } }): string | null {
+ if (g.request.modelId !== AUTO_IMAGE || !g.request.auto) return null;
+ const name = g.modelName ?? g.modelId;
+ const made = g.status === "succeeded" ? `made with ${name}` : g.status === "failed" || g.status === "canceled" ? `tried ${name}` : `making it with ${name}`;
+ return [AUTO_NAME, made, g.request.auto.why === "declined" ? AUTO_DECLINED : null].filter(Boolean).join(" · ");
+}
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 5d6021c3..e8e1c9e6 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -8,6 +8,7 @@ import { QWEN21_DECODER, QWEN21_GPU, QWEN21_SPEED } from "@/lib/qwen21-speed";
import { QMA_AZIMUTHS, QMA_AZIMUTH_LABELS, QMA_DISTANCES, QMA_DISTANCE_LABELS, QMA_DISTANCE_ZOOM, QMA_ELEVATIONS, QMA_ELEVATION_DEGREES, QMA_ELEVATION_LABELS, QMA_MODEL, QMA_PARAMS } from "@/lib/qma";
import { H3_DECODER, H3_FAST_DECODE_OFFERED, H3_GPU_TIER } from "@/lib/gpu/h3-tier";
import { loraEntry, loraRef } from "./loras";
+import { AUTO_IMAGE, AUTO_NAME } from "@/lib/auto-image";
import { ANGLES_LORA, ANY_ANGLE_LORA, MOSAIC_SCALE, MOSAIC_TARGET, SPEAK_GRAPH, SPEAK_LORA, SPEAK_PROMPT } from "./open-tools";
import { ANY_ANGLE } from "./any-angle";
import { RECOLOR_TAP_FIRST } from "./recolor";
@@ -129,6 +130,20 @@ const open: ModelDef[] = [
// ---------------- The owner's newest image models, first picks on your GPU (2026-10-31): text to image in his order
// (Ideogram 4, Qwen-Image 2.1, Krea 2, MOSS-Image, FIBO 2), then the edit models (Qwen-Image 2.1, FIBO 2, Krea 2).
// A studio's "Best" list is its default, then the `top` models in this order (bestForStudio in src/lib/composer.ts).
+ // Auto: the Image studio's default on the open engine. Not a model of its own: the server plans each run on the model it
+ // picks (src/lib/auto-image.ts), and the run names that model. Its routes are its picks' own (Ideogram 4 for words,
+ // Qwen-Image 2.1 for edits), so the picker, the price and the GPU pre-flight read them; it never runs as itself.
+ o({
+ id: AUTO_IMAGE,
+ name: AUTO_NAME,
+ vendor: "Fuobe",
+ family: "auto",
+ kind: "image",
+ tagline: "Picks the model for you: Ideogram 4 for most pictures and lettering, Krea 2 Realism where Ideogram 4 often declines, Qwen-Image 2.1 for edits",
+ routes: [comfy("t2i", "ideogram4-t2i", "Auto picks the model before the run"), { ...comfy("edit", "qwen-image-21-edit", "Auto: Qwen-Image 2.1, up to 4 references"), unsized: true }],
+ options: { aspectRatios: IMG_AR, resolutions: ["1K", "1.5K", "2K"], maxImages: 4, seed: true },
+ defaults: { aspectRatio: "1:1", resolution: "1.5K" },
+ }),
// Ideogram 4: the prompt is a JSON caption the server writes from the words (promptFormat; src/lib/ideogram-caption.ts).
o({
id: "oss-ideogram-4",
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index 9e783aea..4552905a 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -1308,6 +1308,11 @@ export interface GenerationRequest {
chainSkipped?: { slots: number[]; prompt?: string };
/** Server-set: what changed while the job ran (an optional input left out), said on the result and carried down the chain. */
notice?: string;
+ /**
+ * Server-set on a run of Auto (src/lib/auto-image.ts): the model it picked, and why. A run planned again (a resend, a
+ * run that waited to enter the line) is planned on the same model.
+ */
+ auto?: AutoPick;
/**
* A step only worth making for the steps after it (a per-frame render's frame edits and clips): while it still
* waits for its inputs (nothing spent yet), the runner cancels it once every step that would use it has failed
@@ -1587,6 +1592,18 @@ export interface Generation {
declinedCards?: DeclinedCard[];
}
+/**
+ * Why Auto picked its model: a picture to work from ("edit"), lettering ("text"), a prompt the owner's patterns match
+ * ("trigger"), anything else ("plain"), or Ideogram 4 declined the run and this model made it in its place ("declined").
+ */
+export type AutoWhy = "edit" | "text" | "trigger" | "plain" | "declined";
+
+/** The model Auto picked for a run (GenerationRequest.auto). */
+export interface AutoPick {
+ model: string;
+ why: AutoWhy;
+}
+
/** A picture Ideogram 4 returned that was taken for its "blocked" card (Generation.declinedCards). */
export interface DeclinedCard {
url: string;
diff --git a/src/lib/studios.ts b/src/lib/studios.ts
index acc3bbe2..9c8b36cf 100644
--- a/src/lib/studios.ts
+++ b/src/lib/studios.ts
@@ -1,4 +1,5 @@
import { getModel } from "@/lib/catalog";
+import { AUTO_IMAGE } from "@/lib/auto-image";
import { SIGNATURE_MODELS } from "@/lib/catalog/palettes";
import { FACE_MOSAIC_MODELS } from "@/lib/catalog/open-tools";
import { UPSCALE_FIRST_STEPS } from "@/lib/catalog/upscale-first";
@@ -20,10 +21,9 @@ export const IMAGE_STUDIO: StudioConfig = {
slots: [],
// Up to 10 references where the model takes them (FLUX 3 Klein); each model's own limit caps it (composer refMax).
multiRef: { label: "Add ref", max: 10 },
- defaultModels: { cloud: "nano-banana-pro", open: "oss-ideogram-4" },
- // Ideogram 4 runs on a caption the install's local model writes: an account, a guest or an install with none opens on
- // Qwen-Image 2.1, the next pick (plain words give Ideogram's grey safety card on about half the pictures of people).
- uncaptioned: { open: "oss-qwen-image-21" },
+ // Auto picks the open model for each run (src/lib/auto-image.ts): Ideogram 4 for most, Krea 2 Realism for prompts its
+ // safety filter often declines, Qwen-Image 2.1 for edits. The default for everyone: the owner, an account and a guest.
+ defaultModels: { cloud: "nano-banana-pro", open: AUTO_IMAGE },
// A model's own settings (MOSS-Image's Quality, Ideogram's speed) sit under "Options".
controlsTitle: "Options",
// Layout mode: boxes on the picture, one row each, read in place by MOSS-Image, FLUX.3, FLUX 3 Klein and Ideogram 4.5.
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 9ae87bba..ede7f4c6 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -32,6 +32,7 @@ import { finishSteps, mosaicPixels, unionMasks } from "@/lib/soul-post";
import { ANGLES_ORIGINAL, MOSAIC_SCALE } from "@/lib/catalog/open-tools";
import { computeDimensions } from "@/lib/comfy";
import { captionFromWords, captionWords, parseCaption } from "@/lib/ideogram-caption";
+import { AUTO_IMAGE, AUTO_MODELS, autoCandidates, autoPatterns, nextAutoFallback } from "@/lib/auto-image";
import { h3Frames, h3Prompt, inH3Layout } from "@/lib/h3-prompt";
import { h3ReferenceTags, h3TalkPrompt } from "@/lib/h3-references";
import {
@@ -516,6 +517,8 @@ interface PendingMeta {
/** 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). */
+ model?: string;
cards?: DeclinedCard[];
/** Made with Qwen-Image 2.1 now: the run as Ideogram 4's, put back when that fails too (declinedFails). */
was?: DeclinedRun;
@@ -1170,9 +1173,11 @@ function triedRoutes(m: ModelDef, routes: ModelRoute[]): ModelRoute[] {
/** Resolve mentions and drawings, plan, enforce the engine mode and pick a provider route. */
function prepare(original: GenerationRequest) {
+ // Auto runs on the model it picks (autoRouted); the stored request keeps Auto, with its pick.
+ const routed = autoRouted(original);
// @element mentions become reference images / LoRAs; the stored request keeps the mentions for "Reuse".
// A style signature's sentences (palette, look) join the prompt here; the stored request keeps the user's words.
- const worded = withSignatureWords(original);
+ const worded = withSignatureWords(routed);
const mode = engineMode();
// Settings → Models & licences: a model (or the engine of an Original asked for) that is switched off is refused,
// naming the switch; an Original otherwise runs on an engine that is still on, with the routes that are on.
@@ -1300,7 +1305,60 @@ function prepare(original: GenerationRequest) {
const unreachable = asked.filter((l) => !reachable.loras.includes(l));
// Priced for the clip the route makes: Replicate's Wan 2.2 fast makes 5 s when 3 s was asked.
const priced = made !== undefined && plan.params.duration !== undefined ? { ...plan.params, duration: Math.round(made * 2) / 2 } : plan.params;
- return { req, plan, route, demo, providerId, notes, asked, unreachable, switchedOff: access.dropped, gpu: gpu?.gpu, h3: h3 && { gpuTier: h3.gpuTier, ...(h3.unet && { unet: h3.unet }) }, cost: free ? 0 : estimateCost(plan.model, priced, 1, plan.op, withLoras) };
+ return {
+ req,
+ plan,
+ route,
+ demo,
+ providerId,
+ notes,
+ asked,
+ unreachable,
+ switchedOff: access.dropped,
+ gpu: gpu?.gpu,
+ h3: h3 && { gpuTier: h3.gpuTier, ...(h3.unet && { unet: h3.unet }) },
+ cost: free ? 0 : estimateCost(plan.model, priced, 1, plan.op, withLoras),
+ // Auto's pick, which the stored request keeps.
+ ...(routed.auto && { auto: routed.auto }),
+ };
+}
+
+/** Auto's patterns as last read from Settings (the text they were read from, and the patterns). */
+let autoPatternCache: { text: string; patterns: ReturnType<typeof autoPatterns> } | undefined;
+function autoPatternsNow(): ReturnType<typeof autoPatterns> {
+ const text = getSetting("autoImagePatterns");
+ if (autoPatternCache?.text !== text) autoPatternCache = { text, patterns: autoPatterns(text) };
+ return autoPatternCache.patterns;
+}
+
+/**
+ * A run of Auto (src/lib/auto-image.ts) as the model it picks runs it: the pick it carries (a run planned again: a resend,
+ * a run that waited to enter the line, a fallback after Ideogram 4 declined), else the first of its picks for these words
+ * and pictures that is switched on and runs the operation (Settings → Models & licences). A picture to work from makes it
+ * an edit. Any other request as it is.
+ */
+function autoRouted(req: GenerationRequest): GenerationRequest {
+ if (req.modelId !== AUTO_IMAGE) return req;
+ const images = req.inputs?.images?.length ?? 0;
+ if (req.auto && AUTO_MODELS.has(req.auto.model)) {
+ const m = getModel(req.auto.model);
+ const op = req.op && m?.routes.some((r) => r.op === req.op) ? req.op : undefined;
+ return { ...req, modelId: req.auto.model, op: op ?? (images ? "edit" : "t2i") };
+ }
+ const c = autoCandidates({ prompt: req.prompt, op: req.op, images }, autoPatternsNow());
+ const op: Operation = c.why === "edit" ? (req.op && req.op !== "t2i" ? req.op : "edit") : "t2i";
+ const runs = (id: string) => {
+ const m = getModel(id);
+ if (!m?.routes.some((r) => r.op === op)) return false;
+ try {
+ return offeredRoutes(offeredFor(m, "open"), routesFor(m, op)).length > 0;
+ } catch {
+ return false;
+ }
+ };
+ const model = c.models.find(runs);
+ if (!model) throw new Error(op === "t2i" ? "Auto has no image model switched on here. Pick a model" : "Auto has no edit model switched on here. Pick a model");
+ return { ...req, modelId: model, op, auto: { model, why: c.why } };
}
/** The LoRA files a graph loads itself (not injected), so a run downloads the ones ComfyUI lacks before it starts. */
@@ -1499,6 +1557,8 @@ export function createGenerations(sent: GenerationRequest, opts: CreateOptions =
// A dependent job can't be planned until its inputs exist; it's validated with placeholders, then launched by the runner.
const p = waits ? prepare(withChainInputs(original, slotsFor(original, deps.length).map(placeholderFor))) : prepare(original);
const { req, plan, route, demo, providerId, cost } = p;
+ // Auto keeps its pick with the run: planned again, the run goes to the same model, and its tile names it.
+ const kept = p.auto ? { ...original, auto: p.auto } : original;
// A preset whose recipe edited the start frame into an end frame first: two steps (the edit, then the clip).
if (!opts.dependsOn && plan.end) return createEndFrameClip(original, plan.end);
const notes = moved.note ? [moved.note, ...p.notes] : p.notes;
@@ -1526,7 +1586,7 @@ export function createGenerations(sent: GenerationRequest, opts: CreateOptions =
// A step whose prompt comes from an earlier step shows its own words (not the placeholder) until then.
prompt: waits && req.chain?.some((s) => s.slot === "prompt") ? original.prompt?.replaceAll("{text}", "…").trim() || null : plan.prompt,
// An Original remembers the engine it ran on, so a retry or a chained step runs there too.
- request_json: JSON.stringify(dualEngine(plan.model) ? { ...original, engine: plan.model.engine } : original),
+ request_json: JSON.stringify(dualEngine(plan.model) ? { ...kept, engine: plan.model.engine } : kept),
provider_input_json: null,
external_id: null,
external_meta_json: null,
@@ -2947,8 +3007,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 stage = (meta as PendingMeta).declined?.stage;
- return stage && Object.hasOwn(DECLINED_WORDS, stage) ? DECLINED_WORDS[stage] : 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];
}
/**
@@ -2962,14 +3024,15 @@ function keepForOwner(assetIds: readonly string[]): void {
}
/**
- * What Qwen-Image 2.1 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 Qwen-Image 2.1's own settings.
+ * 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.
*/
-function declinedFallback(stored: GenerationRequest): GenerationRequest {
+function declinedFallback(stored: GenerationRequest, modelId: string = DECLINED_FALLBACK_MODEL): GenerationRequest {
const p = stored.params ?? {};
return {
...stored,
- modelId: DECLINED_FALLBACK_MODEL,
+ modelId,
op: stored.inputs?.images?.length ? "edit" : "t2i",
...(stored.prompt && { prompt: captionWords(stored.prompt) }),
params: {
@@ -2984,17 +3047,19 @@ function declinedFallback(stored: GenerationRequest): GenerationRequest {
/**
* 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). 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). Neither 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 both were made already, or a try can't go
- * where the run went: the run fails as before.
+ * (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
+ * let go of the run.
*/
-function declinedAgain(r: Row, declined: DeclinedMeta): boolean {
- const next = !declined.stage ? "retry" : declined.stage === "retry" ? "fallback" : null;
- if (!next) return false;
+function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {
try {
const stored = JSON.parse(r.request_json) as GenerationRequest;
+ const auto = stored.modelId === AUTO_IMAGE;
const account = stored.account;
// Planned where the run went: this install's GPUs (its stamp: place, class, hold), the account's own, or the owner's.
const planned = (req: GenerationRequest) =>
@@ -3003,55 +3068,82 @@ function declinedAgain(r: Row, declined: DeclinedMeta): boolean {
: account
? asAccount(account, () => prepare(req))
: prepare(req);
+ let next: "retry" | "fallback";
let asked = stored;
- let p: ReturnType<typeof prepare>;
- 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) } } };
+ 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 {
- 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);
+ 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);
+ }
}
+ if (p.providerId !== r.provider) return false;
}
- if (p.providerId !== r.provider) return false;
- const was = readMeta(r.external_meta_json);
- const index = jobIndexOf(r, was);
+ 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 fields: Partial<Row> = {
external_id: null,
- external_meta_json: JSON.stringify({ jobIndex: index, declined: { ...declined, stage: next, ...(next === "fallback" && { was: declinedRun(r) }) } }),
+ external_meta_json: JSON.stringify({ jobIndex: index, declined: now }),
// (Working, as it was: not a new run in line.)
status: "running",
progress: null,
- message: DECLINED_WORDS[next],
+ message: declinedWords({ declined: now }) ?? null,
...(next === "fallback" && {
- model_id: p.plan.model.id,
- engine: p.plan.model.engine,
- op: p.plan.op,
- kind: outputKind(p.plan.op, p.plan.model),
- prompt: p.plan.prompt,
- cost_usd: p.cost,
- request_json: JSON.stringify({ ...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: [stored.notice, DECLINED_NOTICE].filter(Boolean).join(" · ") }),
}),
};
- // (Only while the run still goes and is still the job that declined: 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.
+ // (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.
const again = db().transaction((): boolean => {
- if (!updateLive(r.id, fields, " AND external_id = @__ext", { __ext: r.external_id })) return false;
+ if (!updateLive(r.id, fields, " AND external_id IS @__ext", { __ext: r.external_id })) return false;
db().prepare("DELETE FROM generation_runs WHERE id = ?").run(r.id);
noteSubmitTurn(r.id);
return true;
})();
if (!again) return true;
- submitting().add(r.id);
- void submit(r.id, p.route, p.providerId, p.plan, p.req, index);
+ const send = () => {
+ submitting().add(r.id);
+ void submit(r.id, go.route, go.providerId, go.plan, go.req, index);
+ };
+ if (later) setImmediate(send);
+ else send();
return true;
} catch {
return false;
@@ -3059,15 +3151,20 @@ function declinedAgain(r: Row, declined: DeclinedMeta): boolean {
}
/**
- * Qwen-Image 2.1 couldn't make a run Ideogram 4 declined either: 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
- * Qwen-Image 2.1 said goes to the log. Null: not such a run; else whether the run was failed here (it still went).
+ * The model that made a run Ideogram 4 declined couldn't make it either. A run of Auto 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).
*/
function declinedFails(id: string, said: string, metaJson?: string | null): boolean | null {
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}: Qwen-Image 2.1 after Ideogram 4 declined: ${said.slice(0, 500)}`);
+ console.warn(`[generations] ${id}: ${getModel(was.model ?? DECLINED_FALLBACK_MODEL)?.name ?? was.model} 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;
+ }
return updateLive(id, { ...(was.was ?? {}), status: "failed", error: BLOCKED_CARD_MESSAGE, completed_at: Date.now(), message: null });
}
diff --git a/src/server/settings.ts b/src/server/settings.ts
index f2856314..dcb0bba6 100644
--- a/src/server/settings.ts
+++ b/src/server/settings.ts
@@ -1,6 +1,7 @@
import "server-only";
import { AsyncLocalStorage } from "node:async_hooks";
import { PLACE_NAME_MAX } from "@/lib/place-name";
+import { autoPatternsProblems, DEFAULT_AUTO_PATTERNS } from "@/lib/auto-image";
import { db } from "./db";
/**
@@ -135,6 +136,11 @@ export const SETTINGS = {
llmKey: { key: "llm.key", env: "FUOBE_LLM_API_KEY", secret: true },
/** Tokens of context the local model gets (Ollama's num_ctx; LM Studio loads models with it). 0 = the server's own setting. */
llmContext: { key: "llm.context", env: "FUOBE_LLM_CONTEXT", default: "16384" },
+ /**
+ * Settings → Auto image model: prompts Ideogram 4's safety filter often declines, one pattern per line, which Auto sends
+ * to Krea 2 Realism straight away (src/lib/auto-image.ts). Empty: the built-in list.
+ */
+ autoImagePatterns: { key: "auto.imagePatterns", default: DEFAULT_AUTO_PATTERNS.join("\n") },
/** "1" once the first-run guide was put away, or /api/status first saw something the engine mode generates with connected: Home stops offering it. */
onboarded: { key: "onboarding.done", default: "0", options: ["0", "1"] },
} satisfies Record<string, SettingDef>;
@@ -231,6 +237,11 @@ export function validateSetting(name: SettingName, value: string, from: "api" |
if (name === "hostedPlaceName" && value !== "" && (Array.from(value.trim()).length > PLACE_NAME_MAX || /[\u0000-\u001f\u007f-\u009f]/.test(value))) {
throw new Error(`hostedPlaceName must be one line of at most ${PLACE_NAME_MAX} characters`);
}
+ // Auto's patterns: each line one that can be read and doesn't match every prompt (src/lib/auto-image.ts).
+ if (name === "autoImagePatterns" && value !== "") {
+ const problems = autoPatternsProblems(value);
+ if (problems.length) throw new Error(`Auto's patterns: ${problems.join("; ")}`);
+ }
if (name === "smartPlan" && value !== "" && value !== "auto" && !/^[a-z0-9-]{2,32}\|[\w.:/@+-]{1,200}$/.test(value)) {
throw new Error("smartPlan must be auto, or a provider and model as provider|model");
}
diff --git a/tests/auto-image-pool.test.ts b/tests/auto-image-pool.test.ts
new file mode 100644
index 00000000..015dbbdf
--- /dev/null
+++ b/tests/auto-image-pool.test.ts
@@ -0,0 +1,244 @@
+import crypto from "node:crypto";
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import type { Generation } from "@/lib/catalog/types";
+import { startFakeBilling, FAKE_POLICY, type FakeBilling } from "./helpers/fake-billing";
+import { tempDir } from "./helpers/temp-dir";
+
+/**
+ * An account's free run of Auto on this install's GPUs: Auto picks its model there as anywhere, and when Ideogram 4
+ * answers with its grey card, Krea 2 Realism (then FIBO 2 Dev, then MOSS-Image) makes the same run on the same GPUs. One
+ * press of Run stays one run: the hourly count, the runs at once and the billing hold count it once. The card and the
+ * words it declined are the owner's only (Accounts' runs); the account reads which model made its picture. The price
+ * before Run is the picked model's. (The owner's runs: tests/auto-image-runs.test.ts.)
+ */
+
+vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));
+vi.setConfig({ testTimeout: 60_000 });
+
+const dir = tempDir("fuobe-auto-image-pool-");
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:7";
+process.env.OLLAMA_URL = "http://127.0.0.1:7";
+process.env.FUOBE_PUBLIC_SIGNUP = "1";
+delete process.env.FUOBE_PASSWORD;
+delete process.env.FUOBE_HOSTED_RUNS;
+delete process.env.FUOBE_HOSTED_FREE;
+delete process.env.FUOBE_BILLING_URL;
+delete process.env.FUOBE_MODERATION_URL;
+delete process.env.ANTHROPIC_API_KEY;
+globalThis.__fuobeTestDiskFree = 1e13;
+
+const realFetch = globalThis.fetch;
+let allowed: string[] = [];
+globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = String(input instanceof Request ? input.url : input);
+ if (allowed.some((a) => url.startsWith(a))) return realFetch(input, init);
+ return new Response("not reachable in this test", { status: 599 });
+}) as typeof fetch;
+
+const auth = await import("@/server/auth");
+const generationsRoute = await import("@/app/api/generations/route");
+const { db } = await import("@/server/db");
+const { resetRates } = await import("@/server/rate");
+const { setSetting } = await import("@/server/settings");
+const pool = await import("@/server/computer/pool");
+const { catalogVersion } = await import("@/server/computer/catalog-version");
+const billing = await import("@/server/billing");
+const limits = await import("@/server/pool-limits");
+const { comfyProvider, loadManifest } = await import("@/server/providers/comfyui");
+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 { AUTO_IMAGE } = await import("@/lib/auto-image");
+const { autoLine } = await import("@/lib/auto-image");
+const { encodePng } = await import("@/server/png");
+
+const HOST = "localhost:3000";
+const SITE_HEADERS = { host: HOST, "sec-fetch-site": "same-origin", origin: `http://${HOST}` };
+const sha = (s: string) => crypto.createHash("sha256").update(s).digest("hex");
+
+const png = (w: number, h: number, at: (x: number, y: number) => [number, number, number]) => {
+ const data = Buffer.alloc(w * h * 4);
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) data.set([...at(x, y), 255], (y * w + x) * 4);
+ return encodePng({ width: w, height: h, data });
+};
+const card = png(640, 480, (x, y) => (y > 232 && y < 248 && x > 180 && x < 460 && x % 4 < 2 ? [58, 58, 57] : [120, 118, 116]));
+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")}`;
+
+let fake: FakeBilling;
+let n = 0;
+
+function account() {
+ const a = auth.createAccount(`auto-${++n}@example.com`, "long enough");
+ return { id: a.id, cookie: `${auth.SESSION_COOKIE}=${auth.createSession(a.id).value}` };
+}
+
+const post = async (body: Record<string, unknown>, cookie: string, preview = false) => {
+ const text = JSON.stringify(body);
+ const r = await generationsRoute.POST(
+ new Request(`http://${HOST}/api/generations${preview ? "?preview=1" : ""}`, { method: "POST", headers: { ...SITE_HEADERS, cookie, "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) }, body: text }),
+ );
+ return { status: r.status, body: (await r.json()) as { items?: { id: string }[]; code?: string; error?: string; modelId?: string; modelName?: string; place?: string; quote?: Record<string, unknown> } };
+};
+
+/** A worker as the owner adds it, connected: the line is open for the account's runs. */
+function standInWorker() {
+ const w = pool.addWorker(`stand-in-${++n}`);
+ const lanes = allLanes(loadIndex(), sha);
+ pool.patchWorker(w.id, { paused: false, hours: { always: true }, allow: Object.fromEntries(lanes.map((l) => [l.lane, { delayMs: 0 }])), claimAfterMs: 0 });
+ db()
+ .prepare("UPDATE relay_workers SET lanes_json = ?, facts_json = ?, catalog_version = ?, protocol = 3 WHERE id = ?")
+ .run(JSON.stringify({ lanes: lanes.map((l) => l.lane), workflows: loadManifest().workflows.map((x) => x.id) }), JSON.stringify({ vramBytes: 96 * 2 ** 30 }), catalogVersion(), w.id);
+ db().prepare("UPDATE relay_workers SET seen_at = ?, paused_local = 0 WHERE id = ?").run(Date.now(), w.id);
+ return w;
+}
+
+const tick = () => globalThis.__fuobeRunner?.tick();
+async function settled(id: string): Promise<Generation> {
+ const end = Date.now() + 30_000;
+ for (;;) {
+ await tick();
+ const g = getGeneration(id)!;
+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;
+ if (Date.now() > end) throw new Error(`${id} is still ${g.status}`);
+ await new Promise((r) => setTimeout(r, 25));
+ }
+}
+
+/** The jobs the GPUs were sent (the workers' side is stood in for: each job answers at its first look). */
+let sent: { model: string; id: string; tile: Generation; going: number; hourly: number }[] = [];
+let ideogram: Buffer[][] = [];
+let failing = new Set<string>();
+const submit = comfyProvider.submit;
+const poll = comfyProvider.poll;
+const answers = new Map<string, Buffer[]>();
+let accountId = "";
+
+const admitted = (id: string) => db().prepare("SELECT COUNT(*) FROM pool_admissions WHERE account = ?").pluck().get(id) as number;
+const rowsOf = (id: string) => db().prepare("SELECT COUNT(*) FROM generations WHERE json_extract(request_json, '$.account') = ?").pluck().get(id) as number;
+
+beforeAll(async () => {
+ fake = await startFakeBilling();
+ allowed = [fake.url];
+ auth.setPassword("install password");
+});
+afterAll(async () => {
+ globalThis.fetch = realFetch;
+ globalThis.__fuobeTestDiskFree = undefined;
+ for (const k of ["FUOBE_HOSTED_RUNS", "FUOBE_HOSTED_FREE", "FUOBE_BILLING_URL", "FUOBE_BILLING_TOKEN"]) delete process.env[k];
+ await fake.close();
+});
+beforeEach(() => {
+ resetRates();
+ billing.resetBillingCache();
+ process.env.FUOBE_HOSTED_RUNS = "1";
+ process.env.FUOBE_HOSTED_FREE = "1";
+ delete process.env.FUOBE_BILLING_URL;
+ delete process.env.FUOBE_BILLING_TOKEN;
+ fake.policy = { ...FAKE_POLICY };
+ setSetting("comfyWhere", "workers");
+ setSetting("comfyUrl", "");
+ setSetting("engineMode", "open");
+ setSetting("demoMode", "off");
+ setSetting("enhanceProvider", "none");
+ db().prepare("DELETE FROM relay_workers").run();
+ standInWorker();
+ sent = [];
+ ideogram = [];
+ failing = new Set();
+ answers.clear();
+ comfyProvider.submit = async (ctx) => {
+ sent.push({ model: ctx.model.id, id: ctx.generationId, tile: getGeneration(ctx.generationId)!, going: limits.accountActiveRuns(accountId), hourly: admitted(accountId) });
+ return { externalId: `job-${crypto.randomUUID()}`, meta: {} };
+ };
+ comfyProvider.poll = async (ctx) => {
+ if (failing.has(ctx.model.id)) return { state: "failed", error: "Out of memory on the GPU" };
+ let pics = answers.get(ctx.externalId);
+ if (!pics) answers.set(ctx.externalId, (pics = ctx.model.id === "oss-ideogram-4" ? (ideogram.shift() ?? [gradient]) : [gradient]));
+ return { state: "succeeded", outputs: pics.map((p) => ({ url: dataUri(p), kind: "image" as const })) };
+ };
+});
+afterEach(() => {
+ comfyProvider.submit = submit;
+ comfyProvider.poll = poll;
+});
+
+describe("an account's free run of Auto on this install's GPUs", () => {
+ it("Ideogram 4 declines: Krea 2 Realism makes it there at once, and it counts as one run", async () => {
+ const a = account();
+ accountId = a.id;
+ ideogram = [[card]];
+ const r = await post({ feature: "image", modelId: AUTO_IMAGE, 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-krea2-realism");
+ expect(g.request.modelId).toBe(AUTO_IMAGE);
+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "declined" });
+ expect(autoLine(g)).toBe("Auto · made with Krea 2 Realism · Ideogram 4 declined this one");
+ expect(sent.map((s) => [s.model, s.id])).toEqual([
+ ["oss-ideogram-4", id],
+ ["oss-krea2-realism", id],
+ ]);
+ expect(sent[1].tile.status).toBe("running");
+ expect(sent[1].tile.message).toBe("Making it with Krea 2 Realism");
+ expect(sent[1].tile.queue).toBeUndefined();
+ 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();
+ expect(JSON.stringify(getGeneration(id))).not.toContain("spread");
+ const listed = listAccountRuns({ account: a.id }).items.find((x) => x.id === id)!;
+ expect(listed.declinedCards).toHaveLength(1);
+ expect(listed.request.prompt).toBe("a red fox in deep snow");
+ });
+
+ it("each next model only when the one before fails, still one run", async () => {
+ const a = account();
+ accountId = a.id;
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism", "oss-fibo2-dev"]);
+ const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a lighthouse at dusk" }, a.cookie);
+ expect(r.status, JSON.stringify(r.body)).toBe(201);
+ const g = await settled(r.body.items![0].id);
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(sent.map((s) => s.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
+ expect(g.modelId).toBe("oss-moss-image");
+ expect(sent.map((s) => s.hourly)).toEqual([1, 1, 1, 1]);
+ expect(admitted(a.id)).toBe(1);
+ expect(rowsOf(a.id)).toBe(1);
+ });
+
+ it("a prompt the patterns match goes to Krea 2 Realism without an Ideogram 4 job; the price before Run is that model's", async () => {
+ const a = account();
+ accountId = a.id;
+ const cat = { feature: "image", modelId: AUTO_IMAGE, prompt: "a cat in an antique-gold paillette gown, her hair lifting in the wind" };
+ const price = await post(cat, a.cookie, true);
+ expect(price.status, JSON.stringify(price.body)).toBe(200);
+ expect(price.body).toMatchObject({ place: "pool", modelId: "oss-krea2-realism", modelName: "Krea 2 Realism", quote: { allowed: true } });
+ const plain = await post({ ...cat, prompt: "a koi pond at night" }, a.cookie, true);
+ expect(plain.body).toMatchObject({ place: "pool", modelId: "oss-ideogram-4", quote: { allowed: true } });
+ const r = await post(cat, a.cookie);
+ expect(r.status, JSON.stringify(r.body)).toBe(201);
+ const g = await settled(r.body.items![0].id);
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(sent.map((s) => s.model)).toEqual(["oss-krea2-realism"]);
+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "trigger" });
+ expect(admitted(a.id)).toBe(1);
+ });
+
+ it("an account can't read or change Auto's patterns", async () => {
+ const a = account();
+ const { proxy } = await import("@/proxy");
+ const { NextRequest } = await import("next/server");
+ const req = (method: string) => new NextRequest(`http://${HOST}/api/settings`, { method, headers: { ...SITE_HEADERS, cookie: a.cookie, "content-type": "application/json" }, ...(method === "PUT" && { body: JSON.stringify({ autoImagePatterns: "koi" }) }) });
+ expect((await proxy(req("GET"))).status).toBe(403);
+ expect((await proxy(req("PUT"))).status).toBe(403);
+ });
+});
diff --git a/tests/auto-image-runs.test.ts b/tests/auto-image-runs.test.ts
new file mode 100644
index 00000000..f49e3d76
--- /dev/null
+++ b/tests/auto-image-runs.test.ts
@@ -0,0 +1,249 @@
+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { renderToStaticMarkup } from "react-dom/server";
+import type { GenInput, Generation } from "@/lib/catalog/types";
+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.
+vi.setConfig({ testTimeout: 60_000 });
+const dir = tempDir("fuobe-auto-image-runs-");
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9"; // nothing listens here: runs fall back to the demo
+process.env.OLLAMA_URL = "http://127.0.0.1:9";
+delete process.env.ANTHROPIC_API_KEY;
+
+const { setSetting, getSetting, validateSetting } = await import("@/server/settings");
+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 { encodePng } = await import("@/server/png");
+const { db } = await import("@/server/db");
+const { AUTO_IMAGE, DEFAULT_AUTO_PATTERNS } = await import("@/lib/auto-image");
+const { MadeNote } = await import("@/components/studio/made-note");
+
+const png = (w: number, h: number, at: (x: number, y: number) => [number, number, number]) => {
+ const data = Buffer.alloc(w * h * 4);
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) data.set([...at(x, y), 255], (y * w + x) * 4);
+ return encodePng({ width: w, height: h, data });
+};
+// Ideogram 4's grey card, and a real picture.
+const card = png(640, 480, (x, y) => (y > 232 && y < 248 && x > 180 && x < 460 && x % 4 < 2 ? [58, 58, 57] : [120, 118, 116]));
+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, in order; the models that fail; each job handed over, with its run as it read then. */
+let ideogram: Buffer[][] = [];
+let failing = new Set<string>();
+let handed: { model: string; input: GenInput; run: Generation }[] = [];
+const submit = mockProvider.submit;
+const poll = mockProvider.poll;
+const answers = new Map<string, Buffer[]>();
+
+const CAT = "a cat in an antique-gold paillette gown, studio light, her hair lifting in the wind";
+
+beforeAll(() => setSetting("demoMode", "auto"));
+beforeEach(() => {
+ setSetting("enhanceProvider", "none");
+ setSetting("autoImagePatterns", "");
+ changeAccess([{ kind: "reset" }]);
+ ideogram = [];
+ failing = new Set();
+ handed = [];
+ answers.clear();
+ mockProvider.submit = async (ctx) => {
+ handed.push({ model: ctx.model.id, input: ctx.input, run: getGeneration(ctx.generationId)! });
+ return submit(ctx);
+ };
+ mockProvider.poll = async (ctx) => {
+ if (failing.has(ctx.model.id)) return { state: "failed", error: "Out of memory on the GPU" };
+ if (ctx.model.id === "oss-ideogram-4") {
+ let pics = answers.get(ctx.externalId);
+ if (!pics) answers.set(ctx.externalId, (pics = ideogram.shift() ?? [gradient]));
+ return { state: "succeeded", outputs: pics.map((p) => ({ url: dataUri(p), kind: "image" as const })) };
+ }
+ return poll(ctx);
+ };
+});
+afterEach(() => {
+ mockProvider.submit = submit;
+ mockProvider.poll = poll;
+});
+
+const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
+async function settled(id: string, ms = 30_000): Promise<Generation> {
+ const end = Date.now() + ms;
+ for (;;) {
+ const g = getGeneration(id)!;
+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;
+ if (Date.now() > end) throw new Error(`${id} is still ${g.status}`);
+ await sleep(50);
+ }
+}
+async function run(prompt: string, more: Record<string, unknown> = {}, modelId: string = AUTO_IMAGE) {
+ const made = createGenerations({ feature: "image", modelId, prompt, ...more });
+ expect(made).toHaveLength(1);
+ return settled(made[0].id);
+}
+const rowsSince = (id: string) => db().prepare("SELECT COUNT(*) FROM generations WHERE created_at >= (SELECT created_at FROM generations WHERE id = ?)").pluck().get(id) as number;
+const line = (g: Generation) => renderToStaticMarkup(MadeNote({ g })!);
+
+describe("what Auto runs on", () => {
+ it("plain words: Ideogram 4, and the run keeps Auto with its pick", async () => {
+ const g = await run("a red fox in deep snow", { params: { aspectRatio: "16:9" } });
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4"]);
+ expect(g.modelId).toBe("oss-ideogram-4");
+ expect(g.request.modelId).toBe(AUTO_IMAGE);
+ expect(g.request.auto).toEqual({ model: "oss-ideogram-4", why: "plain" });
+ expect(handed[0].input.aspectRatio).toBe("16:9");
+ expect(line(g)).toContain("Auto · made with Ideogram 4");
+ expect(g.request.notice).toBeUndefined();
+ });
+
+ it("lettering: Ideogram 4", async () => {
+ const g = await run("a poster that says GRAND OPENING in gold letters");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4"]);
+ expect(g.request.auto).toEqual({ model: "oss-ideogram-4", why: "text" });
+ });
+
+ it("a prompt the patterns match: Krea 2 Realism straight away, with no Ideogram 4 job", async () => {
+ const g = await run(CAT);
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism"]);
+ expect(g.modelId).toBe("oss-krea2-realism");
+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "trigger" });
+ expect(handed[0].input.prompt).toBe(CAT);
+ expect(line(g)).toContain("Auto · made with Krea 2 Realism");
+ expect(line(g)).not.toContain("declined");
+ });
+
+ it("a picture to work from: Qwen-Image 2.1's edit, never Ideogram 4", async () => {
+ const g = await run("make it golden hour", { inputs: { images: [dataUri(gradient)] } });
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-qwen-image-21"]);
+ expect(g.op).toBe("edit");
+ expect(g.request.auto).toEqual({ model: "oss-qwen-image-21", why: "edit" });
+ });
+
+ it("the owner's own patterns decide, and a model switched off is passed over", async () => {
+ setSetting("autoImagePatterns", "koi");
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }).model.id).toBe("oss-krea2-realism");
+ // The built-in list is gone with it: the cat goes to Ideogram 4 now.
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT }).model.id).toBe("oss-ideogram-4");
+ setSetting("autoImagePatterns", "");
+ expect(getSetting("autoImagePatterns")).toBe(DEFAULT_AUTO_PATTERNS.join("\n"));
+ changeAccess([{ kind: "model", id: "oss-ideogram-4", on: false }]);
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }).model.id).toBe("oss-krea2-realism");
+ });
+
+ it("is priced before Run as the model it would pick (free on a GPU), and a pick it carries stays", () => {
+ const p = previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" });
+ expect(p.model.id).toBe("oss-ideogram-4");
+ expect(p.costUsd).toBe(0);
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT }).model.id).toBe("oss-krea2-realism");
+ // A run planned again (a resend, a run that waited to enter the line) keeps the model it was made with.
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT, auto: { model: "oss-fibo2-dev", why: "declined" } }).model.id).toBe("oss-fibo2-dev");
+ // A pick that isn't one of Auto's is planned again.
+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT, auto: { model: "nano-banana-pro", why: "plain" } }).model.id).toBe("oss-krea2-realism");
+ });
+
+ it("a model picked by name always runs on that model", async () => {
+ const krea = await run("a koi pond at night", {}, "oss-krea2-realism");
+ expect(krea.modelId).toBe("oss-krea2-realism");
+ const ideo = await run(CAT, {}, "oss-ideogram-4");
+ expect(ideo.modelId).toBe("oss-ideogram-4");
+ expect(ideo.request.auto).toBeUndefined();
+ expect(line(ideo)).toBe("");
+ expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism", "oss-ideogram-4"]);
+ });
+});
+
+describe("Auto after Ideogram 4 declines", () => {
+ it("Krea 2 Realism makes the same run at once (no second Ideogram 4 try), and the run says so", async () => {
+ ideogram = [[card]];
+ const g = await run("a red fox in deep snow", { params: { aspectRatio: "4:5", resolution: "1.5K" } });
+ 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.modelId).toBe(AUTO_IMAGE);
+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "declined" });
+ expect(g.request.notice).toBeUndefined();
+ expect(g.outputs).toHaveLength(1);
+ // The same words in plain text, the shape and size asked; Working, saying which model makes it.
+ expect(handed[1].input.prompt).toBe("a red fox in deep snow");
+ expect(handed[1].input.aspectRatio).toBe("4:5");
+ expect(handed[1].run.status).toBe("running");
+ 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);
+ // 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”");
+ expect(line(g)).toContain("Add a pattern");
+ });
+
+ it("each next model only when the one before fails: FIBO 2 Dev, then MOSS-Image", async () => {
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism"]);
+ const fibo = await run("a red fox in deep snow");
+ expect(fibo.status, fibo.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev"]);
+ expect(fibo.modelId).toBe("oss-fibo2-dev");
+ expect(handed[2].run.message).toBe("Making it with FIBO 2 Dev");
+ expect(line(fibo)).toContain("Auto · made with FIBO 2 Dev · Ideogram 4 declined this one");
+
+ handed = [];
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism", "oss-fibo2-dev"]);
+ const moss = await run("a lighthouse at dusk");
+ expect(moss.status, moss.error ?? "").toBe("succeeded");
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
+ expect(moss.modelId).toBe("oss-moss-image");
+ expect(rowsSince(moss.id)).toBe(1);
+ });
+
+ it("when all three fail too, the run fails as Ideogram 4's, in the words it always had, and Retry runs Auto again", async () => {
+ ideogram = [[card]];
+ failing = new Set(["oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
+ const g = await run("a red fox in deep snow");
+ expect(g.status).toBe("failed");
+ expect(g.error).toBe(BLOCKED_CARD_MESSAGE);
+ expect(handed.map((h) => h.model)).toEqual(["oss-ideogram-4", "oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
+ expect(g.modelId).toBe("oss-ideogram-4");
+ expect(g.request.modelId).toBe(AUTO_IMAGE);
+ expect(g.request.auto).toEqual({ model: "oss-ideogram-4", why: "plain" });
+ expect(g.outputs).toEqual([]);
+ expect(g.declinedCards).toHaveLength(1);
+ expect(rowsSince(g.id)).toBe(1);
+ expect(line(g)).toContain("Auto · tried Ideogram 4");
+ });
+
+ it("a fallback switched off is passed over", async () => {
+ changeAccess([{ kind: "model", id: "oss-krea2-realism", on: false }]);
+ ideogram = [[card]];
+ const g = await run("a red fox in deep snow");
+ expect(g.status, g.error ?? "").toBe("succeeded");
+ 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]];
+ 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(g.request.auto).toBeUndefined();
+ });
+});
+
+describe("the setting", () => {
+ it("is checked on save: a line that can't be read, or that matches every prompt, is refused", () => {
+ expect(() => validateSetting("autoImagePatterns", "bikini\n(oops", "api")).toThrow(/Line 2 isn't a pattern/);
+ expect(() => setSetting("autoImagePatterns", ".*")).toThrow(/matches every prompt/);
+ expect(() => validateSetting("autoImagePatterns", "bikini\n# a note\nvelvet cape", "api")).not.toThrow();
+ expect(getSetting("autoImagePatterns")).toBe(DEFAULT_AUTO_PATTERNS.join("\n"));
+ });
+});
diff --git a/tests/auto-image.test.ts b/tests/auto-image.test.ts
new file mode 100644
index 00000000..8f6e9695
--- /dev/null
+++ b/tests/auto-image.test.ts
@@ -0,0 +1,186 @@
+import { describe, expect, it } from "vitest";
+import { renderToStaticMarkup } from "react-dom/server";
+import { getModel, MODELS } from "@/lib/catalog";
+import { planGeneration, estimateCost } from "@/lib/catalog/plan";
+import { getPreset } from "@/lib/catalog";
+import {
+ AUTO_FALLBACKS,
+ AUTO_IMAGE,
+ AUTO_MODELS,
+ autoCandidates,
+ autoLine,
+ autoPatterns,
+ autoPatternsProblems,
+ DEFAULT_AUTO_PATTERNS,
+ matchedPattern,
+ nextAutoFallback,
+} from "@/lib/auto-image";
+import { EDIT_STUDIO, IMAGE_STUDIO, INPAINT_STUDIO } from "@/lib/studios";
+import { withAutoPattern } from "@/components/add-auto-pattern";
+import { MadeNote } from "@/components/studio/made-note";
+import type { Generation } from "@/lib/catalog/types";
+
+// Auto: the open image choice that picks the model for each run (src/lib/auto-image.ts). Its rules on their own here; the
+// runs it makes and their fallbacks: tests/auto-image-runs.test.ts; an account's runs on this install's GPUs:
+// tests/auto-image-pool.test.ts.
+
+const defaults = autoPatterns(DEFAULT_AUTO_PATTERNS.join("\n"));
+const pick = (prompt: string, more: { op?: "t2i" | "edit" | "inpaint" | "outpaint"; images?: number } = {}) => autoCandidates({ prompt, ...more }, defaults);
+
+describe("Auto in the catalog", () => {
+ it("is an open image choice named Auto, next to the models it picks, which keep their names", () => {
+ const m = getModel(AUTO_IMAGE)!;
+ expect(m).toMatchObject({ name: "Auto", engine: "open", kind: "image" });
+ expect(m.routes.map((r) => r.op)).toEqual(["t2i", "edit"]);
+ for (const [id, name] of [
+ ["oss-ideogram-4", "Ideogram 4"],
+ ["oss-krea2-realism", "Krea 2 Realism"],
+ ["oss-fibo2-dev", "FIBO 2 Dev"],
+ ["oss-moss-image", "MOSS-Image"],
+ ["oss-qwen-image-21", "Qwen-Image 2.1"],
+ ])
+ expect(getModel(id)?.name).toBe(name);
+ // Every model it may pick is in the catalog, as an open image model.
+ for (const id of AUTO_MODELS) expect(getModel(id), id).toMatchObject({ engine: "open", kind: "image" });
+ expect(MODELS.filter((x) => x.name === "Auto")).toHaveLength(1);
+ });
+
+ it("is the Image studio's default on the open engine for everyone; Edit and Inpaint keep Qwen-Image 2.1", () => {
+ expect(IMAGE_STUDIO.defaultModels.open).toBe(AUTO_IMAGE);
+ expect(IMAGE_STUDIO.uncaptioned).toBeUndefined();
+ expect(EDIT_STUDIO.defaultModels.open).toBe("oss-qwen-image-21");
+ expect(INPAINT_STUDIO.defaultModels.open).toBe("oss-qwen-image-21");
+ });
+
+ it("plans and prices in the composer like the models it picks: free on a GPU", () => {
+ const plan = planGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }, getModel, getPreset);
+ expect(plan.op).toBe("t2i");
+ expect(estimateCost(plan.model, plan.params, plan.jobs, plan.op)).toBe(0);
+ const edit = planGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "make it dusk", inputs: { images: ["/a.png"] } }, getModel, getPreset);
+ expect(edit.op).toBe("edit");
+ });
+});
+
+describe("what Auto picks", () => {
+ it("a picture to work from: the studio's edit model for its operation, never Ideogram 4", () => {
+ expect(pick("make it golden hour", { images: 1 })).toMatchObject({ models: ["oss-qwen-image-21", "oss-fibo2-dev"], why: "edit" });
+ expect(pick("make it golden hour", { op: "edit", images: 2 }).models[0]).toBe(EDIT_STUDIO.defaultModels.open);
+ expect(pick("a vase of tulips", { op: "inpaint", images: 1 }).models[0]).toBe(INPAINT_STUDIO.defaultModels.open);
+ // Even a poster edit, or a prompt the patterns match.
+ for (const words of ["put the logo on the poster", "a cat in a gown"]) expect(pick(words, { images: 1 }).models).not.toContain("oss-ideogram-4");
+ });
+
+ it("lettering, posters, logos, signs and words in quotes: Ideogram 4", () => {
+ for (const words of [
+ "a film poster for a heist movie",
+ "a minimal logo for a coffee roaster",
+ "bold typography that says SUMMER",
+ "a neon sign above a bar",
+ "hand lettering on a chalkboard menu",
+ "a storefront with “OPEN LATE” painted on the glass",
+ // Lettering wins over a pattern.
+ "a poster of a model in a bikini",
+ ])
+ expect(pick(words), words).toMatchObject({ models: ["oss-ideogram-4", ...AUTO_FALLBACKS], why: "text" });
+ });
+
+ it("prompts Ideogram 4's filter often declines: Krea 2 Realism, then FIBO 2 Dev and MOSS-Image, Ideogram 4 last", () => {
+ for (const words of [
+ "a cat in an antique-gold paillette gown, studio light, her hair lifting in the wind",
+ "a fox wearing a tailored velvet suit at a gala",
+ "an elegant evening gown worn by a white rabbit",
+ "a bear on the red carpet, her hair in curls",
+ "editorial photo of a model in swimwear on a yacht",
+ "a sheer silk blouse, studio portrait",
+ "SEE THROUGH raincoat over a bodysuit",
+ "a nude-tone slip dress",
+ "a nude tone slip dress",
+ ])
+ expect(pick(words), words).toMatchObject({ models: [...AUTO_FALLBACKS, "oss-ideogram-4"], why: "trigger" });
+ expect(pick("a cat in an antique-gold paillette gown").pattern).toMatch(/gowns/);
+ });
+
+ it("everything else: Ideogram 4 first", () => {
+ for (const words of ["a koi pond at night, neon rain", "a cat asleep on a windowsill", "a dog running on a beach", "a woman in a red evening gown on a staircase", "sheerness of the cliffs", "a swimmer at dawn"])
+ expect(pick(words), words).toMatchObject({ models: ["oss-ideogram-4", ...AUTO_FALLBACKS], why: "plain" });
+ });
+
+ it("after Ideogram 4 declines: Krea 2 Realism, FIBO 2 Dev, MOSS-Image, then none", () => {
+ expect(AUTO_FALLBACKS).toEqual(["oss-krea2-realism", "oss-fibo2-dev", "oss-moss-image"]);
+ expect(nextAutoFallback(undefined)).toBe("oss-krea2-realism");
+ expect(nextAutoFallback("oss-krea2-realism")).toBe("oss-fibo2-dev");
+ expect(nextAutoFallback("oss-fibo2-dev")).toBe("oss-moss-image");
+ expect(nextAutoFallback("oss-moss-image")).toBeUndefined();
+ });
+});
+
+describe("the owner's patterns (Settings → Auto image model)", () => {
+ it("the built-in list reads, and its notes are no patterns", () => {
+ expect(autoPatternsProblems(DEFAULT_AUTO_PATTERNS.join("\n"))).toEqual([]);
+ expect(defaults.length).toBe(DEFAULT_AUTO_PATTERNS.filter((l) => !l.startsWith("#")).length);
+ });
+
+ it("a word or phrase matches as a whole word, in any case; any other line is a regular expression", () => {
+ const p = autoPatterns("paillette\nvelvet cape\n\\bglitter(ed)?\\b\n# a note");
+ expect(p.map((x) => x.line)).toEqual(["paillette", "velvet cape", "\\bglitter(ed)?\\b"]);
+ expect(matchedPattern("A PAILLETTE dress", p)).toBe("paillette");
+ expect(matchedPattern("paillettes everywhere", p)).toBeUndefined();
+ expect(matchedPattern("a velvet-cape", p)).toBe("velvet cape");
+ expect(matchedPattern("glittered heels", p)).toBe("\\bglitter(ed)?\\b");
+ // A word or phrase is never read as a pattern: no characters of its own mean anything.
+ expect(matchedPattern("a cat", autoPatterns("a cat"))).toBe("a cat");
+ });
+
+ it("refuses a line that can't be read, matches every prompt, or is too long; and too many lines", () => {
+ expect(autoPatternsProblems("bikini\n(unclosed")).toEqual([expect.stringMatching(/^Line 2 isn't a pattern/)]);
+ expect(autoPatternsProblems(".*")[0]).toMatch(/matches every prompt/);
+ expect(autoPatternsProblems("x?")[0]).toMatch(/matches every prompt/);
+ expect(autoPatternsProblems("a".repeat(301))[0]).toMatch(/over 300 characters/);
+ expect(autoPatternsProblems(Array.from({ length: 201 }, (_, i) => `w${i}`).join("\n"))[0]).toMatch(/200 lines/);
+ expect(autoPatternsProblems("")).toEqual([]);
+ });
+
+ it("Add a pattern puts one line after the list, once, and refuses one that can't be read", () => {
+ expect(withAutoPattern("bikini\nsheer", "paillette")).toBe("bikini\nsheer\npaillette");
+ expect(withAutoPattern("bikini\n", "paillette")).toBe("bikini\npaillette");
+ expect(withAutoPattern("bikini\nsheer", " sheer ")).toBeNull();
+ expect(() => withAutoPattern("bikini", "(")).toThrow(/isn't a pattern/);
+ expect(() => withAutoPattern("bikini", " ")).toThrow(/Type a word/);
+ });
+});
+
+describe("the line under a run of Auto", () => {
+ const run = (o: Partial<Generation> & { auto?: Generation["request"]["auto"]; requestModel?: string }): Generation =>
+ ({
+ id: "g",
+ status: "succeeded",
+ modelId: "oss-ideogram-4",
+ modelName: "Ideogram 4",
+ made: undefined,
+ ...o,
+ request: { feature: "image", modelId: o.requestModel ?? AUTO_IMAGE, prompt: "a cat in a gown", ...(o.auto && { auto: o.auto }) },
+ }) as unknown as Generation;
+
+ it("says what made it, and that Ideogram 4 declined when another model made it", () => {
+ expect(autoLine(run({ auto: { model: "oss-ideogram-4", why: "plain" } }))).toBe("Auto · made with Ideogram 4");
+ expect(autoLine(run({ modelId: "oss-krea2-realism", modelName: "Krea 2 Realism", auto: { model: "oss-krea2-realism", why: "declined" } }))).toBe(
+ "Auto · made with Krea 2 Realism · Ideogram 4 declined this one",
+ );
+ expect(autoLine(run({ status: "running", auto: { model: "oss-ideogram-4", why: "plain" } }))).toBe("Auto · making it with Ideogram 4");
+ expect(autoLine(run({ status: "failed", auto: { model: "oss-ideogram-4", why: "plain" } }))).toBe("Auto · tried Ideogram 4");
+ // A model picked by name says nothing of Auto.
+ expect(autoLine(run({ requestModel: "oss-ideogram-4" }))).toBeNull();
+ });
+
+ it("shows on the feed card and the run details; the owner's review line only with the cards", () => {
+ const g = run({ modelId: "oss-krea2-realism", modelName: "Krea 2 Realism", auto: { model: "oss-krea2-realism", why: "declined" } });
+ const theirs = renderToStaticMarkup(MadeNote({ g })!);
+ expect(theirs).toContain("Auto · made with Krea 2 Realism · Ideogram 4 declined this one");
+ expect(theirs).not.toContain("Add a pattern");
+ expect(theirs).not.toContain("Words:");
+ const owners = renderToStaticMarkup(MadeNote({ g: { ...g, declinedCards: [{ url: "/api/files/card.png", spread: 9, grey: 0.9 }] } })!);
+ expect(owners).toContain("Ideogram 4 declined: what it returned");
+ expect(owners).toContain("Words: “a cat in a gown”");
+ expect(owners).toContain("Add a pattern");
+ });
+});
diff --git a/tests/open-ideogram-4.test.ts b/tests/open-ideogram-4.test.ts
index addc5805..6da629cb 100644
--- a/tests/open-ideogram-4.test.ts
+++ b/tests/open-ideogram-4.test.ts
@@ -310,7 +310,8 @@ describe("Ideogram 4 on the open engine", () => {
expect(m.tagline).toMatch(/24 GB GPU/);
// First among the open-source text-to-image models, after the Originals (the owner's order: Ideogram 4, Qwen-Image 2.1,
// Krea 2, MOSS, FIBO 2).
- expect(MODELS.find((x) => x.id.startsWith("oss-") && x.routes.some((r) => r.op === "t2i"))?.id).toBe("oss-ideogram-4");
+ // (Auto, which picks a model for each run, comes before it: src/lib/auto-image.ts.)
+ expect(MODELS.find((x) => x.id.startsWith("oss-") && x.id !== "oss-auto-image" && x.routes.some((r) => r.op === "t2i"))?.id).toBe("oss-ideogram-4");
const [preset] = m.options.controls!;
expect(preset).toMatchObject({ param: "preset", values: ["Quality", "Default", "Turbo"], default: graph()["98:156"].inputs.choice });
expect(Object.keys(entry()!.bindings)).toContain(preset.param);
diff --git a/tests/open-sota-studios.test.ts b/tests/open-sota-studios.test.ts
index 6b39bc41..a7d5a430 100644
--- a/tests/open-sota-studios.test.ts
+++ b/tests/open-sota-studios.test.ts
@@ -27,8 +27,8 @@ const openIds = MODELS.filter((m) => m.engine === "open").map((m) => m.id);
const before = (a: string, b: string) => expect(openIds.indexOf(a), `${a} before ${b}`).toBeLessThan(openIds.indexOf(b));
describe("studio defaults on your GPU", () => {
- it("Image opens on Ideogram 4, Edit and Inpaint on Qwen-Image 2.1", () => {
- expect(IMAGE_STUDIO.defaultModels.open).toBe("oss-ideogram-4");
+ it("Image opens on Auto (Ideogram 4 for most), Edit and Inpaint on Qwen-Image 2.1", () => {
+ expect(IMAGE_STUDIO.defaultModels.open).toBe("oss-auto-image");
expect(EDIT_STUDIO.defaultModels.open).toBe("oss-qwen-image-21");
expect(INPAINT_STUDIO.defaultModels.open).toBe("oss-qwen-image-21");
expect(getModel("oss-qwen-image-21")!.routes.map((r) => r.op)).toEqual(expect.arrayContaining(["edit", "inpaint", "outpaint"]));
@@ -42,8 +42,8 @@ describe("studio defaults on your GPU", () => {
describe('"Best for this studio" on your GPU', () => {
// FLUX 3 Image Klein (nm10-flux3-klein) sits beside Ideogram 4 and Qwen-Image 2.1, as its brief asks; MOSS-Image moves to
// More models.
- it("Image: Ideogram 4, then Qwen-Image 2.1, FLUX 3 Klein and Krea 2 Realism (MOSS-Image, then FIBO 2 Dev, are next)", () => {
- expect(best(IMAGE_STUDIO, "open")).toEqual(["oss-ideogram-4", "oss-qwen-image-21", "oss-flux3-klein", "oss-krea2-realism"]);
+ it("Image: Auto, then Ideogram 4, Qwen-Image 2.1 and FLUX 3 Klein (Krea 2 Realism, MOSS-Image, then FIBO 2 Dev, are next)", () => {
+ expect(best(IMAGE_STUDIO, "open")).toEqual(["oss-auto-image", "oss-ideogram-4", "oss-qwen-image-21", "oss-flux3-klein"]);
const t2i = MODELS.filter((m) => m.engine === "open" && m.badges?.includes("top") && m.routes.some((r) => r.op === "t2i")).map((m) => m.id);
expect(t2i.indexOf("oss-fibo2-dev")).toBe(5);
});
@@ -263,7 +263,7 @@ describe("what the composer offers for Qwen-Image 2.1's and FIBO 2's edits", ()
});
});
-describe("Ideogram 4 as the Image studio's default", () => {
+describe("Auto as the Image studio's default", () => {
const owner = (helper: string, local: unknown) => ({ llm: { helper, local } });
it("is the default only where the server writes its caption with a local model", () => {
@@ -276,14 +276,11 @@ describe("Ideogram 4 as the Image studio's default", () => {
expect(writesCaptions({ viewer: { kind: "guest", gpu: { connected: false } } })).toBe(false);
});
- it("gives way to Qwen-Image 2.1 without a caption writer; nothing changes while the status loads or in the cloud", () => {
+ it("is the default for everyone: the owner, an account and a guest, with or without a caption writer", () => {
const d = IMAGE_STUDIO.defaultModels;
- expect(viewerDefaults(d, IMAGE_STUDIO.uncaptioned, false)).toEqual({ cloud: "nano-banana-pro", open: "oss-qwen-image-21" });
- expect(viewerDefaults(d, IMAGE_STUDIO.uncaptioned, true)).toBe(d);
- expect(viewerDefaults(d, IMAGE_STUDIO.uncaptioned, undefined)).toBe(d);
+ expect(IMAGE_STUDIO.uncaptioned).toBeUndefined();
+ for (const writes of [false, true, undefined]) expect(viewerDefaults(d, IMAGE_STUDIO.uncaptioned, writes)).toBe(d);
expect(viewerDefaults(EDIT_STUDIO.defaultModels, EDIT_STUDIO.uncaptioned, false)).toBe(EDIT_STUDIO.defaultModels);
- const studio = { ...IMAGE_STUDIO, defaultModels: viewerDefaults(d, IMAGE_STUDIO.uncaptioned, false) };
- expect(best(studio, "open")).toEqual(["oss-qwen-image-21", "oss-ideogram-4", "oss-flux3-klein", "oss-krea2-realism"]);
});
});