Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(prompts): seed a MiniMax H3 Ref2VA structured-prompt system prompt
Lincoln Steina627598d1c65
diff --git a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.pynew file mode 100644index 0000000000..61377c29af--- /dev/null+++ b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py@@ -0,0 +1,107 @@+"""Seed the "MiniMax H3 Ref2VA Structured Prompt" system prompt for the Expand Prompt button.++MiniMax H3's ``ref2va`` conditioning presents each attached reference under a per-modality+label (``<Picture i>``/``<Video k>``/``<Audio j>`` — see+:mod:`invokeai.backend.minimax_h3.text_conditioning`) and the model responds best to a prompt+organised into the sectioned form the seeded prompt below teaches.++This is a separate migration rather than another entry in+``migration_2026_07_10_create_system_prompts.DEFAULT_SYSTEM_PROMPTS`` because the migrator runs+each id exactly once: appending to that list would only reach databases created after this+release. Seeding here uses the same fixed-UUID / ``INSERT OR IGNORE`` shape, so a prompt the+user has since edited or deleted stays edited or deleted.+"""++import sqlite3++from invokeai.app.services.shared.sqlite_migrator.sqlite_migrator_common import Migration++MINIMAX_H3_REF2VA_PROMPT_ID = "0f8f5b2e-1c9e-4f2a-9a4e-1f1f1f1f0008"+MINIMAX_H3_REF2VA_PROMPT_NAME = "MiniMax H3 Ref2VA Structured Prompt"++MINIMAX_H3_REF2VA_PROMPT_CONTENT = """You are a prompt engineer for MiniMax H3 `ref2va` (reference-to-video-with-audio). Rewrite the user's free-form description into the structured prompt format below, preserving their intent and inventing nothing about their reference media.++## How references are labelled++The generator sees every attached reference under a per-modality label, numbered in attachment order: images are `<Picture 1>`, `<Picture 2>`, ...; videos are `<Video 1>`, `<Video 2>`, ...; audio — including the soundtrack carried by a video — is `<Audio 1>`, `<Audio 2>`, .... Refer to references only by these labels. Give each person, animal, or object that is carried from a reference into the generated video its own `<Subject 1>`, `<Subject 2>`, ... label, and use that subject label everywhere afterwards instead of re-describing it.++## Required output format++Emit these sections, in this order, with the headings spelled exactly as shown:++### subject_definitions+One bullet per reference and per subject: what the reference contains, and which reference each `<Subject N>` is drawn from.++### summary+One or two sentences stating what the finished video shows.++### retention_analysis+One bullet per reference, tagged with how that reference is used:+- `fully_preserved` - the reference's content must survive intact (an identity, a face, a garment, a logo).+- `attribute_transfer` - only a named attribute is borrowed (motion, camera move, lighting, style, rhythm); say which.++### detailed_description+The shot list. Open each shot with `[Shot 1]`, `[Shot 2]`, ... and describe, in the present tense, the camera movement, the subject action, the setting, and the lighting. Use a single shot unless the user asked for more.++### overall_soundscape+The diegetic sound — what is audible within the scene itself. Write `N/A` if the video should be silent.++### non_diegetic_music+Score laid over the scene. Write `N/A` when there is none, which is the usual case unless the user asked for music.++## Rules++1. Use only what the user gave you. Where a section needs a fact the user did not supply — how many references there are, what one of them depicts, which subject it defines, what the scene sounds like — write `[TO FILL]` in place of the missing detail rather than guessing. A partly known bullet keeps what is known and marks only the gap, for example `- <Picture 1>: [TO FILL] - the source of <Subject 1>`.+2. Never invent a reference the user did not mention. When the user refers to references only vaguely ("my photo", "the clip"), emit the labels those imply and mark their contents `[TO FILL]`.+3. Keep the user's own wording wherever they were specific; expand only the concrete visual and audible detail around it.+4. Describe what is seen and heard, objectively and in the present tense. Avoid subjective praise ("beautiful", "stunning") and avoid self-reference ("this video shows") outside the summary.+5. Output the structured prompt only - no preamble, no commentary, no code fences.++## Example of the shape++### subject_definitions+- <Picture 1>: A close-up photo of a woman with red hair.+- <Video 1>: A reference video of a person walking down a hallway.+- <Subject 1>: The woman from <Picture 1>.++### summary+The video shows <Subject 1> walking down a bright office hallway, replicating the camera tracking from <Video 1>.++### retention_analysis+- <Picture 1>: fully_preserved - the visual identity and hair color of the woman.+- <Video 1>: attribute_transfer - transfer only the walking motion and camera angle.++### detailed_description+[Shot 1]+The camera tracks backward at a steady pace. <Subject 1> walks forward down a brightly lit office hallway towards the camera.++### overall_soundscape+The clear sound of high heels clicking rhythmically on a hard tile floor.++### non_diegetic_music+N/A"""+++class AddMiniMaxH3Ref2VASystemPromptCallback:+ def __call__(self, cursor: sqlite3.Cursor) -> None:+ # Same contract as the original seed: owned by 'system', shared with everyone, and skipped+ # outright if the id is already present.+ cursor.execute(+ """--sql+ INSERT OR IGNORE INTO system_prompts (id, name, content, user_id, is_public)+ VALUES (?, ?, ?, 'system', TRUE);+ """,+ (MINIMAX_H3_REF2VA_PROMPT_ID, MINIMAX_H3_REF2VA_PROMPT_NAME, MINIMAX_H3_REF2VA_PROMPT_CONTENT),+ )+++def build_migration() -> Migration:+ """Seed the MiniMax H3 Ref2VA structured-prompt system prompt.++ Depends on the migration that creates and first seeds ``system_prompts``.+ """+ return Migration(+ id="2026_09_07_add_minimax_h3_ref2va_system_prompt",+ depends_on="2026_07_10_create_system_prompts",+ callback=AddMiniMaxH3Ref2VASystemPromptCallback(),+ )diff --git a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.pynew file mode 100644index 0000000000..8b414b9142--- /dev/null+++ b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py@@ -0,0 +1,78 @@+import sqlite3++from invokeai.app.services.shared.sqlite_migrator.migrations.migration_2026_07_10_create_system_prompts import (+ DEFAULT_SYSTEM_PROMPTS,+ CreateSystemPromptsCallback,+)+from invokeai.app.services.shared.sqlite_migrator.migrations.migration_2026_09_07_add_minimax_h3_ref2va_system_prompt import (+ MINIMAX_H3_REF2VA_PROMPT_CONTENT,+ MINIMAX_H3_REF2VA_PROMPT_ID,+ MINIMAX_H3_REF2VA_PROMPT_NAME,+ AddMiniMaxH3Ref2VASystemPromptCallback,+ build_migration,+)+++def _seeded_db() -> sqlite3.Connection:+ db = sqlite3.connect(":memory:")+ CreateSystemPromptsCallback()(db.cursor())+ return db+++def test_seeds_the_prompt_shared_and_owned_by_system() -> None:+ db = _seeded_db()+ cursor = db.cursor()++ AddMiniMaxH3Ref2VASystemPromptCallback()(cursor)++ cursor.execute(+ "SELECT name, content, user_id, is_public FROM system_prompts WHERE id = ?;",+ (MINIMAX_H3_REF2VA_PROMPT_ID,),+ )+ assert cursor.fetchone() == (MINIMAX_H3_REF2VA_PROMPT_NAME, MINIMAX_H3_REF2VA_PROMPT_CONTENT, "system", 1)+ cursor.execute("SELECT COUNT(*) FROM system_prompts;")+ assert cursor.fetchone()[0] == len(DEFAULT_SYSTEM_PROMPTS) + 1++ db.close()+++def test_id_does_not_collide_with_the_original_seed() -> None:+ assert MINIMAX_H3_REF2VA_PROMPT_ID not in {default_id for default_id, _, _ in DEFAULT_SYSTEM_PROMPTS}+++def test_is_idempotent_and_preserves_user_edits() -> None:+ # Migrations run once per id, but a re-run must not duplicate the row or undo an edit.+ db = _seeded_db()+ cursor = db.cursor()++ AddMiniMaxH3Ref2VASystemPromptCallback()(cursor)+ cursor.execute("UPDATE system_prompts SET content = 'edited by user' WHERE id = ?;", (MINIMAX_H3_REF2VA_PROMPT_ID,))++ AddMiniMaxH3Ref2VASystemPromptCallback()(cursor)++ cursor.execute("SELECT content FROM system_prompts WHERE id = ?;", (MINIMAX_H3_REF2VA_PROMPT_ID,))+ assert cursor.fetchone()[0] == "edited by user"+ cursor.execute("SELECT COUNT(*) FROM system_prompts;")+ assert cursor.fetchone()[0] == len(DEFAULT_SYSTEM_PROMPTS) + 1++ db.close()+++def test_prompt_teaches_every_required_section() -> None:+ # The whole point of the prompt is the section contract; a dropped heading silently degrades+ # the structure the model emits.+ for heading in (+ "### subject_definitions",+ "### summary",+ "### retention_analysis",+ "### detailed_description",+ "### overall_soundscape",+ "### non_diegetic_music",+ ):+ assert heading in MINIMAX_H3_REF2VA_PROMPT_CONTENT+ assert "[TO FILL]" in MINIMAX_H3_REF2VA_PROMPT_CONTENT+++def test_migration_id_matches_its_module_name() -> None:+ assert build_migration().id == "2026_09_07_add_minimax_h3_ref2va_system_prompt"+ assert build_migration().depends_on == "2026_07_10_create_system_prompts"