Skip to content

FLUX.3 [klein] prompts; edit optimizer sees the pictures - #265

Merged
iamwavecut merged 1 commit into
mainfrom
feat/flux3-image-model
Oct 16, 2026
Merged

iamwavecut merged 1 commit into
mainfrom
feat/flux3-image-model

Conversation

@iamwavecut

Copy link
Copy Markdown
Owner

What

  • Prompt target. ImageModel is now Flux3 | Krea2. A routed model tagged prompt_target: "flux3", or an untagged one, gets FLUX.3 [klein] prompts. Krea 2 keeps its rules. The FLUX.2 [klein], Boogu-Image and Qwen-Image targets are removed, and their tag values now fall back to FLUX.3.
  • Draw optimizer (prompts/image/optimizer.prompt). The prompt follows the FLUX.3 prompt upsampler: medium-first captions, frame-relative layout, quoted text kept verbatim, 100–350 words. It merges the visual-prompt-expand rules with the existing request, context, aspect-ratio, NSFW and safety rules. Short or vague requests expand into complete scenes. The few-shot examples are eight text-to-image samples from flux3-klein-pup-50k across different domains, plus authored Cyrillic-text, adult and forbidden cases.
  • Edit optimizer (prompts/image/edit_optimizer.prompt). Instructions use the upsampler's own form: "Create a preserving the first image as the exact canvas, changing only …", with picture ordinals, concrete end states and consequences, operation-specific boundaries and one compact preservation clause. The few-shot examples are nine image-to-image samples from the dataset plus the official two-reference example, with authored adult and forbidden cases.
  • The edit optimizer sees the pictures. MediaPromptOptimizer::optimize_image_edit_prompt takes image data URLs. OptimizingImageEditor loads the edit's pictures through the bot's Telegram client (image_edit_references.rs). It resizes them to the upsampler's reference policy (1024², 724² or 512² by picture count, sides on a multiple of 32, JPEG q92) and sends them before the request with the upsampler's line Reference images follow in order (…). This works on the OpenAI-compatible path and on the Gemini path.
    • Telegram file URLs contain the bot token, so the model never receives them, and download errors do not repeat the URL.
    • If any picture fails to load or decode, the optimizer works from the text alone. A partial set would renumber the pictures the request refers to.
  • Corner mark. The flux3_generate endpoint gets the same corner mark as FLUX.2 outputs.

Why

FLUX.3 [klein] (Heretic text encoder, W4A8) replaces Boogu for regular draws and the second VIP slot, and replaces Qwen-Image for VIP edits. FLUX.3 was trained on its upsampler's captions and instructions, and that upsampler sees the reference pictures when it writes an edit.

Verification

  • cargo fmt --all --check passes.
  • cargo clippy --workspace --all-targets -- -D warnings passes.
  • cargo test -p openplotva-media -p openplotva-llm -p openplotva-app passes: 47, 217 and 1418 tests.
  • New tests cover:
    • the reference-size policy, checked against the upsampler's formula, including its 200:1 aspect limit;
    • the order line;
    • image-then-text content parts in the structured request;
    • picture loading and encoding: resizing, alpha flattened onto white, a broken picture failing the whole set, the Telegram path taken from the URL, and inline base64;
    • the optimizing editor with pictures and with failed pictures;
    • prompt targets and the FLUX.3 mark.

FLUX.3 [klein] replaces FLUX.2 [klein], Boogu-Image and Qwen-Image as
the prompt target: routed models tagged prompt_target "flux3" (and
untagged ones) get FLUX.3 captions and edit instructions, Krea 2 keeps
its own rules.

The draw and edit optimizer prompts follow the official prompt
upsampler: medium-first captions with frame-relative layout and quoted
text for drawing, "Create a ... preserving the first image as the
exact canvas" instructions with picture ordinals for editing, merged
with the visual-prompt-expand rules and few-shot examples taken from
the flux3-klein-pup-50k dataset.

The edit optimizer now sees the pictures the way the upsampler does:
the bot downloads them through its Telegram client, resizes them to
the upsampler's reference policy (1024², 724² or 512² by count, sides
on a multiple of 32, JPEG q92), and sends them before the request with
the upsampler's reference order line. Telegram file URLs carry the bot
token and never reach the model. When a picture cannot be prepared the
optimizer works from the text alone.

FLUX.3 outputs get the same corner mark as FLUX.2 outputs.
@github-actions

Copy link
Copy Markdown
Warnings
⚠️ Prompt files are cache-sensitive contracts; confirm prompt shape and role markers were preserved intentionally.
⚠️ Large PR (1193 changed lines). Consider splitting unless this is generated/mechanical.
Messages
📖 Danger checked 9 changed file(s).

Generated by 🚫 dangerJS against d363065

@iamwavecut

Copy link
Copy Markdown
Owner Author

Both Danger warnings are intentional.

  • Prompt files. The rewrite of both optimizer prompts is the point of this PR. The template contract is unchanged: variant_count, slots and multi render as before, and the model flags change from klein/boogu/qwen_image to flux3, matching optimizer_prompt_data. The prompts have no partials or role markers, before or after. The rendering tests in openplotva-media cover every slot combination.
  • Large PR. One change delivers the new prompt target, the prompts written for it, and the pictures the edit optimizer needs for that format. Splitting it would ship FLUX.3 edit instructions that refer to pictures the optimizer cannot see.

@iamwavecut
iamwavecut merged commit 12e87b1 into main Oct 16, 2026
12 checks passed
@iamwavecut
iamwavecut deleted the feat/flux3-image-model branch October 16, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant