Tighten Krea2 POV selector formatting
This commit is contained in:
+52
-2
@@ -4,6 +4,10 @@ from dataclasses import dataclass
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
MOUTH_EXPRESSION_TERMS = ("mouth", "oral", "tongue", "lips", "gagging", "saliva", "drool")
|
||||
TOP_VIEW_ORAL_VARIANT = "pov_blowjob_top_down_vertical_shaft"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class KreaPairFormatRequest:
|
||||
row: dict[str, Any]
|
||||
@@ -54,6 +58,45 @@ class KreaPairFormatDependencies:
|
||||
combine_negative: Callable[..., str]
|
||||
|
||||
|
||||
def _list_values(value: Any) -> list[str]:
|
||||
if isinstance(value, list):
|
||||
return [str(item) for item in value if str(item).strip()]
|
||||
if isinstance(value, str) and value.strip():
|
||||
return [part.strip() for part in value.split(",") if part.strip()]
|
||||
return []
|
||||
|
||||
|
||||
def _krea2_variant_keys(row: dict[str, Any]) -> list[str]:
|
||||
config = row.get("hardcore_position_config") if isinstance(row.get("hardcore_position_config"), dict) else {}
|
||||
axis_values = row.get("item_axis_values") if isinstance(row.get("item_axis_values"), dict) else {}
|
||||
return list(dict.fromkeys([*_list_values(config.get("krea2_variant_keys")), *_list_values(axis_values.get("krea2_variant_keys"))]))
|
||||
|
||||
|
||||
def _has_krea2_variant(row: dict[str, Any], key: str) -> bool:
|
||||
return key in _krea2_variant_keys(row)
|
||||
|
||||
|
||||
def _filter_expression_for_krea2_variant(row: dict[str, Any], expression: Any) -> Any:
|
||||
if not _has_krea2_variant(row, TOP_VIEW_ORAL_VARIANT):
|
||||
return expression
|
||||
clauses = [clause.strip() for clause in str(expression or "").split(";") if clause.strip()]
|
||||
if not clauses:
|
||||
return expression
|
||||
kept = [
|
||||
clause
|
||||
for clause in clauses
|
||||
if not any(term in clause.lower() for term in MOUTH_EXPRESSION_TERMS)
|
||||
]
|
||||
return "; ".join(kept)
|
||||
|
||||
|
||||
def _filter_camera_scene_for_krea2_variant(row: dict[str, Any], camera_scene: Any) -> str:
|
||||
text = str(camera_scene or "")
|
||||
if _has_krea2_variant(row, TOP_VIEW_ORAL_VARIANT) and "eye-level" in text.lower():
|
||||
return ""
|
||||
return text
|
||||
|
||||
|
||||
def format_insta_pair_result(request: KreaPairFormatRequest, deps: KreaPairFormatDependencies) -> KreaPairPrompts:
|
||||
row = request.row
|
||||
detail_level = request.detail_level
|
||||
@@ -70,7 +113,10 @@ def format_insta_pair_result(request: KreaPairFormatRequest, deps: KreaPairForma
|
||||
soft_camera = deps.pair_camera_phrase(row.get("softcore_camera_directive"), row.get("softcore_camera_config"), soft)
|
||||
hard_camera = deps.pair_camera_phrase(row.get("hardcore_camera_directive"), row.get("hardcore_camera_config"), hard)
|
||||
soft_camera_scene = deps.camera_scene_phrase(soft) or deps.clean(row.get("softcore_camera_scene_directive"))
|
||||
hard_camera_scene = deps.camera_scene_phrase(hard) or deps.clean(row.get("hardcore_camera_scene_directive"))
|
||||
hard_camera_scene = _filter_camera_scene_for_krea2_variant(
|
||||
hard,
|
||||
deps.camera_scene_phrase(hard) or deps.clean(row.get("hardcore_camera_scene_directive")),
|
||||
)
|
||||
soft_style = deps.style_phrase(soft, style_mode)
|
||||
hard_style = deps.style_phrase(hard, style_mode)
|
||||
options = row.get("options") if isinstance(row.get("options"), dict) else {}
|
||||
@@ -166,8 +212,12 @@ def format_insta_pair_result(request: KreaPairFormatRequest, deps: KreaPairForma
|
||||
)
|
||||
hard_expression = ""
|
||||
if not deps.expression_disabled(hard):
|
||||
hard_expression_source = deps.filter_pov_labeled_clauses(
|
||||
hard_expression_source = _filter_expression_for_krea2_variant(
|
||||
hard,
|
||||
deps.clean(hard.get("character_expression_text")) or deps.clean(hard.get("expression")),
|
||||
)
|
||||
hard_expression_source = deps.filter_pov_labeled_clauses(
|
||||
hard_expression_source,
|
||||
pov_labels,
|
||||
)
|
||||
hard_expression = deps.natural_label_text(
|
||||
|
||||
Reference in New Issue
Block a user