Route pair metadata structurally

This commit is contained in:
2026-06-27 15:13:31 +02:00
parent 728d3e559c
commit e7bc227c6f
6 changed files with 35 additions and 6 deletions
+17 -1
View File
@@ -81,11 +81,27 @@ def maybe_json(text: Any) -> dict[str, Any] | None:
def normalize_input_metadata(row: dict[str, Any]) -> dict[str, Any]:
row = dict(row)
trigger = str(row.get("trigger") or "").strip()
if row.get("mode") == "Insta/OF":
if is_pair_metadata(row):
return row_normalization_policy.normalize_pair_metadata(row, active_trigger=trigger)
return row_normalization_policy.sanitize_metadata_row_text(row, active_trigger=trigger)
def is_pair_metadata(row: Any) -> bool:
if not isinstance(row, dict):
return False
soft_side = (
isinstance(row.get("softcore_row"), dict)
or bool(clean_text(row.get("softcore_prompt")))
or bool(clean_text(row.get("softcore_caption")))
)
hard_side = (
isinstance(row.get("hardcore_row"), dict)
or bool(clean_text(row.get("hardcore_prompt")))
or bool(clean_text(row.get("hardcore_caption")))
)
return soft_side and hard_side
def normalize_input_hint(value: Any, *, text_hint: str = INPUT_HINT_PROMPT) -> str:
hint = clean_text(value).lower().replace("-", "_")
hint = _INPUT_HINT_ALIASES.get(hint, hint)