fix: 优化架构

This commit is contained in:
Daniel
2026-03-25 19:35:37 +08:00
parent 34786b37c7
commit 508c28ce31
184 changed files with 2199 additions and 241 deletions

23
engine/prompt_injector.py Normal file
View File

@@ -0,0 +1,23 @@
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}