Only prepend referenced character descriptions
This commit is contained in:
@@ -375,12 +375,20 @@ def _character_prompt_replacements(characters: list[dict]) -> dict[str, str]:
|
|||||||
return replacements
|
return replacements
|
||||||
|
|
||||||
|
|
||||||
def _prepend_character_descriptions(global_prompt: str, characters: list[dict] | None = None) -> str:
|
def _prepend_referenced_character_descriptions(
|
||||||
descriptions = [
|
global_prompt: str,
|
||||||
(character.get("description", "") or "").strip()
|
local_prompts: str,
|
||||||
for character in (characters or [])
|
characters: list[dict] | None = None,
|
||||||
if (character.get("description", "") or "").strip()
|
) -> str:
|
||||||
]
|
prompt_text = f"{global_prompt or ''} {local_prompts or ''}"
|
||||||
|
descriptions = []
|
||||||
|
for character, tags in zip(characters or [], _build_character_tag_groups(characters or [])):
|
||||||
|
description = (character.get("description", "") or "").strip()
|
||||||
|
if not description:
|
||||||
|
continue
|
||||||
|
if any(tag in prompt_text for tag in tags):
|
||||||
|
descriptions.append(description)
|
||||||
|
|
||||||
if not descriptions:
|
if not descriptions:
|
||||||
return global_prompt or ""
|
return global_prompt or ""
|
||||||
|
|
||||||
@@ -2099,7 +2107,7 @@ class LTXDirector(io.ComfyNode):
|
|||||||
image_cache=image_cache,
|
image_cache=image_cache,
|
||||||
input_dir=input_dir,
|
input_dir=input_dir,
|
||||||
)
|
)
|
||||||
global_prompt = _prepend_character_descriptions(global_prompt, characters)
|
global_prompt = _prepend_referenced_character_descriptions(global_prompt, local_prompts, characters)
|
||||||
char_slot_images = [list(character.get("images") or []) for character in characters]
|
char_slot_images = [list(character.get("images") or []) for character in characters]
|
||||||
char_images = [img for slot_images in char_slot_images for img in slot_images]
|
char_images = [img for slot_images in char_slot_images for img in slot_images]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user