Centralize formatter input hints
This commit is contained in:
@@ -2685,9 +2685,36 @@ def smoke_formatter_input_policy() -> None:
|
||||
}
|
||||
source_json = _json(source_row)
|
||||
|
||||
_expect(
|
||||
formatter_input.input_hint_choices(text_hint=formatter_input.INPUT_HINT_PROMPT) == ["auto", "metadata_json", "prompt"],
|
||||
"Formatter prompt input-hint choices changed",
|
||||
)
|
||||
_expect(
|
||||
formatter_input.input_hint_choices(text_hint=formatter_input.INPUT_HINT_CAPTION_OR_PROMPT)
|
||||
== ["auto", "metadata_json", "caption_or_prompt"],
|
||||
"Formatter caption input-hint choices changed",
|
||||
)
|
||||
_expect(
|
||||
formatter_input.normalize_input_hint("bad_hint") == "auto",
|
||||
"Formatter input-hint policy should normalize invalid values to auto",
|
||||
)
|
||||
_expect(
|
||||
formatter_input.normalize_input_hint("caption", text_hint=formatter_input.INPUT_HINT_CAPTION_OR_PROMPT)
|
||||
== "caption_or_prompt",
|
||||
"Formatter input-hint policy lost caption alias",
|
||||
)
|
||||
_expect(
|
||||
formatter_input.normalize_input_hint("caption_or_prompt", text_hint=formatter_input.INPUT_HINT_PROMPT) == "prompt",
|
||||
"Formatter input-hint policy should map text hints to the route's text mode",
|
||||
)
|
||||
|
||||
row, method = formatter_input.row_from_inputs(source_json, "", "auto")
|
||||
_expect(method == "source_json", "Formatter input parser should read source JSON when metadata is empty")
|
||||
_expect(row == source_row, "Formatter input parser changed parsed JSON row")
|
||||
row, method = formatter_input.row_from_inputs(source_json, "", "bad_hint")
|
||||
_expect(method == "source_json" and row == source_row, "Formatter input parser should treat invalid hints as auto")
|
||||
row, method = formatter_input.row_from_inputs(source_json, "", "prompt")
|
||||
_expect(row is None and method == "text", "Formatter input parser should not parse source JSON in explicit prompt mode")
|
||||
_expect(formatter_input.split_avoid("Prompt body. Avoid: blur, watermark") == ("Prompt body", "blur, watermark"), "Avoid split changed")
|
||||
_expect(
|
||||
formatter_input.prompt_field(source_row["prompt"], "Setting") == "quiet studio",
|
||||
@@ -2745,6 +2772,32 @@ def smoke_formatter_input_policy() -> None:
|
||||
_expect_text("formatter_input.krea_prompt", krea.get("krea_prompt"), 20)
|
||||
_expect_text("formatter_input.sdxl_prompt", sdxl.get("sdxl_prompt"), 20)
|
||||
_expect_text("formatter_input.caption", caption, 20)
|
||||
|
||||
bad_hint_krea = krea_formatter.format_krea2_prompt(source_json, input_hint="bad_hint")
|
||||
bad_hint_sdxl = sdxl_formatter.format_sdxl_prompt(
|
||||
source_json,
|
||||
input_hint="bad_hint",
|
||||
trigger=SdxlTrigger,
|
||||
prepend_trigger=True,
|
||||
)
|
||||
bad_hint_caption, bad_hint_caption_method = caption_naturalizer.naturalize_caption(
|
||||
source_json,
|
||||
input_hint="bad_hint",
|
||||
trigger=Trigger,
|
||||
)
|
||||
_expect(
|
||||
bad_hint_krea.get("method", "").startswith("source_json:krea2("),
|
||||
"Krea formatter did not normalize bad input hint to auto",
|
||||
)
|
||||
_expect(
|
||||
bad_hint_sdxl.get("method", "").startswith("source_json:sdxl("),
|
||||
"SDXL formatter did not normalize bad input hint to auto",
|
||||
)
|
||||
_expect(
|
||||
bad_hint_caption_method.startswith("source_json:metadata("),
|
||||
"Caption formatter did not normalize bad input hint to auto",
|
||||
)
|
||||
|
||||
fallback_sdxl = sdxl_formatter.format_sdxl_prompt(
|
||||
"Characters: woman. Erotic outfit: sheer dress. Camera: side view. Avoid: blur",
|
||||
input_hint="prompt",
|
||||
|
||||
Reference in New Issue
Block a user