Extract Krea row field policy

This commit is contained in:
2026-06-27 11:42:14 +02:00
parent d7caf1c270
commit 8fc3abc504
5 changed files with 153 additions and 50 deletions
+36
View File
@@ -48,6 +48,7 @@ import krea_configured_cast_formatter # noqa: E402
import krea_formatter # noqa: E402
import krea_normal_formatter # noqa: E402
import krea_pair_formatter # noqa: E402
import krea_row_fields # noqa: E402
import location_config # noqa: E402
import loop_nodes # noqa: E402
import pair_builder # noqa: E402
@@ -649,6 +650,40 @@ def smoke_krea_normal_row_routes() -> None:
_expect_krea_normal_route_parity(generic, "krea_normal_generic", "metadata(generic)")
def smoke_krea_row_fields_policy() -> None:
row = {
"subject_type": "configured_cast",
"primary_subject": "woman",
"cast_summary": "1 woman, 1 man",
"item": "lace bodysuit fashion editorial styling",
"pose": "standing close together",
"scene_text": "private room with warm lamps",
"expression": "soft smile",
"expression_enabled": False,
"composition": "vertical tight two-person frame",
"source_composition": "vertical source action frame",
"camera_directive": "Camera: eye-level close-up",
"camera_scene_directive": "Camera-aware scene layout.",
"style": "realistic social photo",
}
fields = krea_row_fields.extract_krea_row_fields(
row,
"preserve",
krea_formatter._krea_row_field_dependencies(),
)
normal_request = krea_formatter._krea_normal_row_request_from_row(row, "balanced", "preserve")
cast_request = krea_formatter._krea_configured_cast_request_from_row(row, "balanced", "preserve")
_expect(fields.item == "lace bodysuit", "Krea row fields did not strip generic styling suffix")
_expect(fields.expression == "", "Krea row fields ignored expression disabled flag")
_expect(fields.composition == "tight two-person frame", "Krea row fields did not normalize composition prefix")
_expect(fields.source_composition == "source action frame", "Krea row fields did not normalize source composition")
_expect(normal_request.item == fields.item, "Normal Krea route item extraction drifted")
_expect(cast_request.item == fields.item, "Configured-cast Krea route item extraction drifted")
_expect(normal_request.expression == cast_request.expression == fields.expression, "Krea route expression extraction drifted")
_expect(normal_request.camera == cast_request.camera == fields.camera, "Krea route camera extraction drifted")
_expect(cast_request.source_composition == fields.source_composition, "Configured-cast source composition drifted")
def smoke_location_config_policy() -> None:
_expect(pb.LOCATION_POOL_PRESETS is location_config.LOCATION_POOL_PRESETS, "Prompt builder location presets are not delegated")
_expect(pb.COMPOSITION_POOL_PRESETS is location_config.COMPOSITION_POOL_PRESETS, "Prompt builder composition presets are not delegated")
@@ -5256,6 +5291,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
("row_camera_policy", smoke_row_camera_policy),
("config_route_location_theme", smoke_config_route_location_theme),
("krea_normal_row_routes", smoke_krea_normal_row_routes),
("krea_row_fields_policy", smoke_krea_row_fields_policy),
("location_config_policy", smoke_location_config_policy),
("row_location_policy", smoke_row_location_policy),
("row_expression_policy", smoke_row_expression_policy),