Extract SDXL format dispatch route

This commit is contained in:
2026-06-27 12:26:00 +02:00
parent 837299be6c
commit 1ee0b6e91a
5 changed files with 338 additions and 82 deletions
+122
View File
@@ -79,6 +79,7 @@ import row_route_metadata # noqa: E402
import row_subject_route # noqa: E402
import server_routes # noqa: E402
import sdxl_formatter # noqa: E402
import sdxl_format_route # noqa: E402
import sdxl_presets # noqa: E402
import sdxl_tag_policy # noqa: E402
import sdxl_tag_routes # noqa: E402
@@ -2763,6 +2764,126 @@ def smoke_sdxl_presets_policy() -> None:
_expect("score_9" not in profiled_prompt, "SDXL photo profile should switch away from Pony score quality tail")
def smoke_sdxl_format_route_policy() -> None:
row = _prompt_row(
name="sdxl_format_route_single",
category="woman",
subcategory="random",
seed=3701,
men_count=0,
camera_config=_orbit_camera(horizontal_angle=45, vertical_angle=0, zoom=5.5),
)
single_request = sdxl_format_route.SDXLFormatRequest(
source_text="",
metadata_json=_json(row),
target="single",
style_preset="flat_vector_pony",
quality_preset="pony_high",
trigger=SdxlTrigger,
prepend_trigger=True,
nude_weight=9.0,
extra_positive="sdxl route marker",
extra_negative="sdxl route negative",
formatter_profile="sdxl_photo",
)
typed_single = sdxl_format_route.format_sdxl_prompt_result(
single_request,
sdxl_formatter._sdxl_format_dependencies(),
)
public_single = sdxl_formatter.format_sdxl_prompt(
"",
metadata_json=single_request.metadata_json,
target=single_request.target,
style_preset=single_request.style_preset,
quality_preset=single_request.quality_preset,
trigger=single_request.trigger,
prepend_trigger=single_request.prepend_trigger,
nude_weight=single_request.nude_weight,
extra_positive=single_request.extra_positive,
extra_negative=single_request.extra_negative,
formatter_profile=single_request.formatter_profile,
)
_expect(typed_single.output == public_single, "Typed SDXL format route should match public single formatter output")
_expect(typed_single.branch == "metadata", "Typed SDXL format route changed single branch")
_expect(typed_single.target == "single", "Typed SDXL format route lost target normalization")
_expect(typed_single.nude_weight == 3.0, "Typed SDXL format route should clamp high nude weight")
_expect(typed_single.style_preset == "photographic", "Typed SDXL format route lost profile style override")
_expect("sdxl route marker" in typed_single.output.get("sdxl_prompt", ""), "Typed SDXL route lost extra positive")
_expect("sdxl route negative" in typed_single.output.get("negative_prompt", ""), "Typed SDXL route lost extra negative")
pair = pb.build_insta_of_pair(
row_number=1,
start_index=1,
seed=3702,
ethnicity="any",
figure="random",
no_plus_women=False,
no_black=False,
trigger=Trigger,
prepend_trigger_to_prompt=True,
options_json=_insta_options(),
character_cast=_character_cast(),
hardcore_position_config=_action_filter("penetration_only"),
)
pair_request = sdxl_format_route.SDXLFormatRequest(
source_text="",
metadata_json=_json(pair),
target="hardcore",
trigger=SdxlTrigger,
prepend_trigger=True,
extra_positive="pair sdxl route marker",
extra_negative="pair sdxl route negative",
)
typed_pair = sdxl_format_route.format_sdxl_prompt_result(
pair_request,
sdxl_formatter._sdxl_format_dependencies(),
)
public_pair = sdxl_formatter.format_sdxl_prompt(
"",
metadata_json=pair_request.metadata_json,
target=pair_request.target,
trigger=pair_request.trigger,
prepend_trigger=pair_request.prepend_trigger,
extra_positive=pair_request.extra_positive,
extra_negative=pair_request.extra_negative,
)
_expect(typed_pair.output == public_pair, "Typed SDXL format route should match public pair formatter output")
_expect(typed_pair.branch == "insta_of_pair", "Typed SDXL format route changed pair branch")
_expect_text("sdxl_format_route_policy.hard_prompt", typed_pair.output.get("sdxl_hardcore_prompt"), 40)
_expect("pair sdxl route marker" in typed_pair.output.get("sdxl_prompt", ""), "Typed SDXL pair route lost extra positive")
fallback_request = sdxl_format_route.SDXLFormatRequest(
source_text="Characters: woman. Erotic outfit: sheer dress. Camera: side view. Avoid: blur",
input_hint="prompt",
target="weird",
trigger=SdxlTrigger,
prepend_trigger=False,
nude_weight=0.01,
style_preset="none",
quality_preset="none",
)
typed_fallback = sdxl_format_route.format_sdxl_prompt_result(
fallback_request,
sdxl_formatter._sdxl_format_dependencies(),
)
public_fallback = sdxl_formatter.format_sdxl_prompt(
fallback_request.source_text,
input_hint=fallback_request.input_hint,
target=fallback_request.target,
trigger=fallback_request.trigger,
prepend_trigger=fallback_request.prepend_trigger,
nude_weight=fallback_request.nude_weight,
style_preset=fallback_request.style_preset,
quality_preset=fallback_request.quality_preset,
)
_expect(typed_fallback.output == public_fallback, "Typed SDXL format route should match public fallback output")
_expect(typed_fallback.branch == "fallback", "Typed SDXL format route changed fallback branch")
_expect(typed_fallback.target == "auto", "Typed SDXL format route should normalize invalid target")
_expect(typed_fallback.nude_weight == 0.1, "Typed SDXL format route should clamp low nude weight")
_expect("Characters:" not in typed_fallback.output.get("sdxl_prompt", ""), "Typed SDXL fallback leaked Characters label")
_expect("blur" in typed_fallback.output.get("negative_prompt", ""), "Typed SDXL fallback route lost Avoid negative")
def smoke_sdxl_tag_policy() -> None:
row = _fixture_hardcore_row(
action_family="oral",
@@ -5628,6 +5749,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
("caption_text_policy", smoke_caption_text_policy),
("caption_metadata_routes", smoke_caption_metadata_routes),
("sdxl_presets_policy", smoke_sdxl_presets_policy),
("sdxl_format_route_policy", smoke_sdxl_format_route_policy),
("sdxl_tag_policy", smoke_sdxl_tag_policy),
("sdxl_tag_routes", smoke_sdxl_tag_routes),
("hardcore_position_config_policy", smoke_hardcore_position_config_policy),