from __future__ import annotations from typing import Any def inject_prompt(global_cfg: dict[str, Any] | None, scene: dict[str, Any]) -> dict[str, str]: """ Unified positive/negative prompt builder. Note: current pipeline already injects some globals into `scene["image_prompt"]`. """ global_cfg = global_cfg or {} character = str(global_cfg.get("character", "") or "").strip() style = str(global_cfg.get("style", "") or "").strip() negative = str(global_cfg.get("negative_prompt", "") or "").strip() base = str(scene.get("prompt") or scene.get("image_prompt") or "").strip() if not base: base = str(scene.get("image_prompt") or "") positive_parts = [p for p in [character, style, base] if p] positive = ", ".join(positive_parts).strip(", ") return {"positive": positive, "negative": negative}