添加输入提示词
This commit is contained in:
@@ -13,6 +13,7 @@ from .nodes.prompt_combine import CombinePrompt, MultiCombinePrompt
|
||||
from .nodes.prompt_replace import ReplacePrompt, MultiReplacePrompt
|
||||
from .nodes.prompt_custom import CustomPrompt
|
||||
from .nodes.prompt_save import SavePrompt
|
||||
from .nodes.prompt_text import InputPrompt, RandomLinePrompt
|
||||
from .nodes.prompt_preview import PreviewPrompt
|
||||
|
||||
|
||||
@@ -35,6 +36,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
"MultiReplacePrompt": MultiReplacePrompt,
|
||||
"CustomPrompt": CustomPrompt,
|
||||
"SavePrompt": SavePrompt,
|
||||
"InputPrompt": InputPrompt,
|
||||
"RandomLinePrompt": RandomLinePrompt,
|
||||
"PreviewPrompt": PreviewPrompt,
|
||||
}
|
||||
|
||||
@@ -56,6 +59,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"MultiReplacePrompt": "Multi Replace Prompt",
|
||||
"CustomPrompt": "Custom Prompt",
|
||||
"SavePrompt": "Save Prompt",
|
||||
"InputPrompt": "Input Prompt",
|
||||
"RandomLinePrompt": "Random Line Prompt",
|
||||
"PreviewPrompt", "Preview Prompt",
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import os
|
||||
|
||||
|
||||
# Input Prompt
|
||||
class InputPrompt:
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"text": ("STRING", {
|
||||
"default": "",
|
||||
"multiline": True
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("text",)
|
||||
FUNCTION = "input_prompt"
|
||||
CATEGORY = "PromptWrapper"
|
||||
|
||||
def input_prompt(self, text=""):
|
||||
|
||||
return (text, )
|
||||
|
||||
|
||||
|
||||
|
||||
# Random Line Prompt
|
||||
class RandomLinePrompt:
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"text": ("STRING", {
|
||||
"default": "",
|
||||
"multiline": True,
|
||||
"tooltip" : "string split is use \\n character."
|
||||
}),
|
||||
"seed": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 0xFFFFFFFFFFFFFFFF
|
||||
})
|
||||
},
|
||||
"optional": {
|
||||
"input_prompt": ("STRING", {"forceInput": True}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("text",)
|
||||
FUNCTION = "random_text"
|
||||
OUTPUT_NODE = True
|
||||
CATEGORY = "PromptWrapper"
|
||||
|
||||
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 = ""
|
||||
line_count = len(output_texts)
|
||||
if line_count > 0:
|
||||
line_index = seed % line_count
|
||||
output_prompt = output_texts[line_index]
|
||||
|
||||
return (output_prompt, )
|
||||
Reference in New Issue
Block a user