From 340e4ff01595c16bd824d46fa8b1e198b3c62094 Mon Sep 17 00:00:00 2001 From: DreamFly Date: Sun, 13 Apr 2025 12:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 3 ++- nodes/prompt_preview.py | 9 ++++++--- nodes/prompt_text.py | 16 +++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index 4dd2741..e635ffa 100644 --- a/__init__.py +++ b/__init__.py @@ -64,4 +64,5 @@ NODE_DISPLAY_NAME_MAPPINGS = { "PreviewPrompt": "Preview Prompt", } -__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] + diff --git a/nodes/prompt_preview.py b/nodes/prompt_preview.py index a873c2e..48ef0a2 100644 --- a/nodes/prompt_preview.py +++ b/nodes/prompt_preview.py @@ -11,7 +11,8 @@ class PreviewPrompt: "text": ("STRING", {"forceInput": True}), }, "hidden": { - "unique_id": "UNIQUE_ID" + "unique_id": "UNIQUE_ID", + "extra_pnginfo": "EXTRA_PNGINFO", }, } @@ -20,10 +21,12 @@ class PreviewPrompt: RETURN_NAMES = ("text",) FUNCTION = "preview" OUTPUT_NODE = True + OUTPUT_IS_LIST = (True,) + INPUT_IS_LIST = True CATEGORY = "PromptWrapper" - def preview(self, text, unique_id=None): - + def preview(self, text, unique_id=None, extra_pnginfo=None): + return {"ui": {"text": text}, "result": (text,)} diff --git a/nodes/prompt_text.py b/nodes/prompt_text.py index ed58d5e..3f5081c 100644 --- a/nodes/prompt_text.py +++ b/nodes/prompt_text.py @@ -61,20 +61,22 @@ class RandomLinePrompt: def random_text(self, text="", seed=0, input_prompt=""): output_texts = [] - if input_prompt != "": - lines = input_prompt.split("\n") - for line in lines: - output_texts.append(line) - if text != "": lines = text.split("\n") for line in lines: output_texts.append(line) - output_prompt = "" + output_words = [] + if input_prompt != "": + output_words.append(input_prompt) + line_count = len(output_texts) if line_count > 0: line_index = seed % line_count - output_prompt = output_texts[line_index] + output_words.append(output_texts[line_index]) + + output_prompt = "" + if len(output_words) > 0: + output_prompt = ", ".join(output_words) return (output_prompt, ) \ No newline at end of file