diff --git a/caption_naturalizer.py b/caption_naturalizer.py index f06bb37..a11b936 100644 --- a/caption_naturalizer.py +++ b/caption_naturalizer.py @@ -23,26 +23,7 @@ STYLE_TAILS = [ ", coloured pencil comic illustration, crisp linework, hatching, soft pastel palette, warm sensual lighting, textured paper", ] -PROMPT_FIELD_LABELS = ( - "Ages", - "Body types", - "Cast", - "Cast descriptors", - "Characters", - "Scene", - "Setting", - "Pose", - "Sexual pose", - "Facial expression", - "Facial expressions", - "Clothing", - "Erotic outfit", - "Prop/detail", - "Composition", - "Role graph", - "Use", - "Avoid", -) +PROMPT_FIELD_LABELS = input_policy.prompt_field_labels() ITEM_LABELS = ( "Sexual pose", diff --git a/docs/prompt-architecture-improvement-plan.md b/docs/prompt-architecture-improvement-plan.md index 525d3a9..37502aa 100644 --- a/docs/prompt-architecture-improvement-plan.md +++ b/docs/prompt-architecture-improvement-plan.md @@ -73,7 +73,8 @@ routes: - JSON row detection from `metadata_json` or source text; - trigger-prefix stripping with route-specific trigger candidate lists; - `Avoid:` positive/negative splitting for fallback text; -- prompt field extraction such as `Setting:` or `Composition:`; +- the shared prompt field-label inventory and extraction such as `Setting:`, + `Sexual scene:`, `Camera control:`, or `Composition:`; - row-value fallback from metadata fields to labeled prompt text. It must not make formatter-style decisions. Krea prose, SDXL tags, and training @@ -261,8 +262,9 @@ Already isolated: first-person body geometry, and selected-position-axis priority before loose context fallback. - `formatter_input.py` owns shared metadata/source JSON detection, trigger - stripping, prompt-field extraction, `Avoid:` splitting, and row-value - fallback for Krea, SDXL, and caption routes. + stripping, the shared prompt field-label inventory, prompt-field extraction, + `Avoid:` splitting, and row-value fallback for Krea, SDXL, and caption + routes. Improve later: diff --git a/docs/prompt-pool-routing-map.md b/docs/prompt-pool-routing-map.md index bf93ab7..43669fb 100644 --- a/docs/prompt-pool-routing-map.md +++ b/docs/prompt-pool-routing-map.md @@ -95,7 +95,7 @@ Core helper ownership: | `krea_cast.py` | Shared formatter cast descriptor parsing, cast labels, cast prose, natural cast descriptor text, and label replacement used by Krea2 and caption routes. | | `prompt_hygiene.py` | Generic prompt, caption, and negative-prompt cleanup. | | `row_normalization.py` | Final prompt-row and pair metadata normalization: trigger prepending, extra-positive append, negative merge/dedupe, caption-part joining, and embedded soft/hard row sanitation. | -| `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. | +| `formatter_input.py` | Shared formatter input parsing: text cleanup, metadata/source JSON detection, trigger-prefix stripping, shared prompt field-label inventory, `Avoid:` splitting, prompt-field extraction, and metadata row-value fallback. | | `sdxl_presets.py` | SDXL style presets, quality presets, default negative prompt, and metadata-family tag hints used by the SDXL formatter and node choice lists. | ## Node IO Map diff --git a/formatter_input.py b/formatter_input.py index f64570c..133c6d5 100644 --- a/formatter_input.py +++ b/formatter_input.py @@ -30,6 +30,10 @@ DEFAULT_PROMPT_FIELD_LABELS = ( ) +def prompt_field_labels() -> tuple[str, ...]: + return DEFAULT_PROMPT_FIELD_LABELS + + def clean_text(value: Any) -> str: text = "" if value is None else str(value) text = text.replace("\n", " ") diff --git a/krea_formatter.py b/krea_formatter.py index 7852fb9..3e9abf7 100644 --- a/krea_formatter.py +++ b/krea_formatter.py @@ -69,26 +69,7 @@ TRIGGER_CANDIDATES = ( "sxcpinup_coloredpencil", "sxcppnl7", ) -PROMPT_FIELD_LABELS = ( - "Ages", - "Body types", - "Cast", - "Cast descriptors", - "Characters", - "Scene", - "Setting", - "Pose", - "Sexual pose", - "Facial expression", - "Facial expressions", - "Clothing", - "Erotic outfit", - "Prop/detail", - "Composition", - "Role graph", - "Use", - "Avoid", -) +PROMPT_FIELD_LABELS = input_policy.prompt_field_labels() def _clean(value: Any) -> str: diff --git a/sdxl_formatter.py b/sdxl_formatter.py index 5ec75f0..603ada8 100644 --- a/sdxl_formatter.py +++ b/sdxl_formatter.py @@ -27,27 +27,7 @@ SDXL_DEFAULT_NEGATIVE = sdxl_policy.SDXL_DEFAULT_NEGATIVE SDXL_ACTION_FAMILY_TAGS = sdxl_policy.SDXL_ACTION_FAMILY_TAGS SDXL_POSITION_FAMILY_TAGS = sdxl_policy.SDXL_POSITION_FAMILY_TAGS -PROMPT_FIELD_LABELS = ( - "Ages", - "Body types", - "Cast", - "Cast descriptors", - "Characters", - "Scene", - "Setting", - "Pose", - "Sexual pose", - "Sexual scene", - "Facial expression", - "Facial expressions", - "Clothing", - "Erotic outfit", - "Composition", - "Role graph", - "Camera control", - "Use", - "Avoid", -) +PROMPT_FIELD_LABELS = input_policy.prompt_field_labels() def sdxl_style_preset_choices() -> list[str]: diff --git a/tools/prompt_smoke.py b/tools/prompt_smoke.py index 9607bbe..1234072 100644 --- a/tools/prompt_smoke.py +++ b/tools/prompt_smoke.py @@ -882,6 +882,27 @@ def smoke_formatter_input_policy() -> None: formatter_input.row_value({"prompt": source_row["prompt"]}, "scene_text", ("Setting",)) == "quiet studio", "Row value prompt fallback changed", ) + _expect( + krea_formatter.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS, + "Krea formatter field-label inventory should delegate to formatter_input", + ) + _expect( + sdxl_formatter.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS, + "SDXL formatter field-label inventory should delegate to formatter_input", + ) + _expect( + caption_naturalizer.PROMPT_FIELD_LABELS is formatter_input.DEFAULT_PROMPT_FIELD_LABELS, + "Caption formatter field-label inventory should delegate to formatter_input", + ) + labeled_prompt = "Sexual scene: close-contact action. Camera control: side view. Composition: centered frame." + _expect( + formatter_input.prompt_field(labeled_prompt, "Sexual scene") == "close-contact action", + "Shared formatter field-label inventory lost Sexual scene parsing", + ) + _expect( + formatter_input.prompt_field(labeled_prompt, "Camera control") == "side view", + "Shared formatter field-label inventory lost Camera control parsing", + ) _expect(krea_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "Krea clean helper is not delegated") _expect(sdxl_formatter._clean("a b , c") == formatter_input.clean_text("a b , c"), "SDXL clean helper is not delegated")