Extract row expression policy
This commit is contained in:
@@ -51,6 +51,7 @@ import pov_policy # noqa: E402
|
||||
import row_normalization # noqa: E402
|
||||
import route_metadata # noqa: E402
|
||||
import row_camera # noqa: E402
|
||||
import row_expression # noqa: E402
|
||||
import row_location # noqa: E402
|
||||
import row_pools # noqa: E402
|
||||
import server_routes # noqa: E402
|
||||
@@ -658,6 +659,79 @@ def smoke_row_location_policy() -> None:
|
||||
_expect(", long archive aisle composition," in updated.get("caption", ""), "Row location policy did not rewrite caption composition")
|
||||
|
||||
|
||||
def smoke_row_expression_policy() -> None:
|
||||
entries = [
|
||||
{"text": "quiet calm focus", "weight": 2.0},
|
||||
{"text": "heated smirk", "weight": 3.0},
|
||||
{"text": "dazed overwhelmed look", "weight": 1.0},
|
||||
]
|
||||
_expect(
|
||||
pb._expression_entries_for_intensity(entries, 0.25) == row_expression.expression_entries_for_intensity(entries, 0.25),
|
||||
"Prompt builder expression intensity wrapper should delegate to row_expression",
|
||||
)
|
||||
weighted = row_expression.expression_entries_for_intensity(entries, 0.25)
|
||||
_expect(weighted[0]["weight"] == 8.0, "Row expression low-intensity weighting changed")
|
||||
_expect(weighted[2]["weight"] == 0.05, "Row expression distant-intensity weighting changed")
|
||||
|
||||
row = {
|
||||
"prompt": "Person with quiet focus, in room. Facial expression: quiet focus. Keep this.",
|
||||
"caption": "sxcppnl7, person with quiet focus, in room",
|
||||
"expression": "quiet focus",
|
||||
"shared_expression": "quiet focus",
|
||||
"character_expressions": ["Woman A has quiet focus"],
|
||||
"character_expression_text": "Woman A has quiet focus",
|
||||
}
|
||||
_expect(
|
||||
pb._disable_row_expression(dict(row), "test") == row_expression.disable_row_expression(dict(row), "test"),
|
||||
"Prompt builder expression disable wrapper should delegate to row_expression",
|
||||
)
|
||||
disabled = row_expression.disable_row_expression(dict(row), "test")
|
||||
_expect(disabled.get("expression_disabled") is True, "Row expression disable did not set disabled metadata")
|
||||
_expect("quiet focus" not in disabled.get("prompt", ""), "Row expression disable did not strip prompt expression text")
|
||||
|
||||
woman_slot = character_slot.normalize_character_slot(
|
||||
{
|
||||
"subject_type": "woman",
|
||||
"label": "A",
|
||||
"expression_intensity": 0.8,
|
||||
"softcore_expression_intensity": 0.2,
|
||||
}
|
||||
)
|
||||
pov_man_slot = character_slot.normalize_character_slot(
|
||||
{
|
||||
"subject_type": "man",
|
||||
"label": "A",
|
||||
"presence_mode": "pov",
|
||||
"expression_intensity": 1.0,
|
||||
}
|
||||
)
|
||||
label_map = {"Woman A": woman_slot, "Man A": pov_man_slot}
|
||||
_expect(
|
||||
pb._cast_expression_intensity_override(0.5, label_map, 1, 1, "softcore")
|
||||
== row_expression.cast_expression_intensity_override(0.5, label_map, 1, 1, "softcore"),
|
||||
"Prompt builder cast expression override wrapper should delegate to row_expression",
|
||||
)
|
||||
_expect(
|
||||
row_expression.cast_expression_intensity_override(0.5, label_map, 1, 1, "softcore")
|
||||
== (0.2, "character_slot:Woman A"),
|
||||
"Row expression cast override did not prefer visible slot phase intensity",
|
||||
)
|
||||
_expect(
|
||||
pb._character_expression_entries(random.Random(22), entries, 0.5, label_map, 1, 1, "softcore")
|
||||
== row_expression.character_expression_entries(random.Random(22), entries, 0.5, label_map, 1, 1, "softcore"),
|
||||
"Prompt builder character expression wrapper should delegate to row_expression",
|
||||
)
|
||||
|
||||
disabled_slot = character_slot.normalize_character_slot(
|
||||
{"subject_type": "woman", "label": "A", "expression_enabled": False}
|
||||
)
|
||||
_expect(
|
||||
row_expression.cast_expression_intensity_override(0.5, {"Woman A": disabled_slot}, 1, 0, "hardcore")
|
||||
== (None, "character_slots:disabled"),
|
||||
"Row expression cast override did not honor all-slot expression disable",
|
||||
)
|
||||
|
||||
|
||||
def smoke_category_cast_config_policy() -> None:
|
||||
_expect(pb.CATEGORY_PRESETS is category_cast_config.CATEGORY_PRESETS, "Prompt builder category presets are not delegated")
|
||||
_expect(pb.CAST_PRESETS is category_cast_config.CAST_PRESETS, "Prompt builder cast presets are not delegated")
|
||||
@@ -3856,6 +3930,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
|
||||
("config_route_location_theme", smoke_config_route_location_theme),
|
||||
("location_config_policy", smoke_location_config_policy),
|
||||
("row_location_policy", smoke_row_location_policy),
|
||||
("row_expression_policy", smoke_row_expression_policy),
|
||||
("category_cast_config_policy", smoke_category_cast_config_policy),
|
||||
("generation_profile_config_policy", smoke_generation_profile_config_policy),
|
||||
("filter_config_policy", smoke_filter_config_policy),
|
||||
|
||||
Reference in New Issue
Block a user