This commit is contained in:
DreamFly
2025-04-13 12:08:14 +08:00
parent 3e63a43bd6
commit 340e4ff015
3 changed files with 17 additions and 11 deletions
+2 -1
View File
@@ -64,4 +64,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"PreviewPrompt": "Preview Prompt",
}
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
+6 -3
View File
@@ -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,)}
+9 -7
View File
@@ -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, )