Centralize negative prompt hygiene

This commit is contained in:
2026-06-27 14:01:10 +02:00
parent 333fa5eae6
commit 4fdef3875b
7 changed files with 38 additions and 9 deletions
+3 -4
View File
@@ -3,9 +3,9 @@ from __future__ import annotations
from typing import Any
try:
from .prompt_hygiene import sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
from .prompt_hygiene import combine_negative_text, sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
except ImportError: # Allows local smoke tests with `python tools/prompt_smoke.py`.
from prompt_hygiene import sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
from prompt_hygiene import combine_negative_text, sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
def _trigger_tuple(active_trigger: str) -> tuple[str, ...]:
@@ -24,8 +24,7 @@ def prepend_trigger(prompt: str, trigger: str, enabled: bool) -> str:
def combined_negative(base: str, extra: str) -> str:
parts = [str(part).strip() for part in (base, extra) if part and str(part).strip()]
return ", ".join(parts)
return combine_negative_text(base, extra)
def caption_from_parts(parts: list[Any] | tuple[Any, ...], *, active_trigger: str = "") -> str: