36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
class FL_PromptSelector:
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"prepend_text": ("STRING", {"multiline": True, "default": ""}),
|
|
"prompts": ("STRING", {"multiline": True}),
|
|
"append_text": ("STRING", {"multiline": True, "default": ""}),
|
|
"index": ("INT", {"default": 0, "min": 0, "max": 100, "step": 1}),
|
|
},
|
|
"optional": {},
|
|
}
|
|
|
|
RETURN_TYPES = ("STRING",)
|
|
FUNCTION = "select_prompt"
|
|
CATEGORY = "🏵️Fill Nodes"
|
|
|
|
def select_prompt(self, prepend_text, prompts, append_text, index):
|
|
prepend_text = prepend_text.strip()
|
|
prompt_lines = prompts.split("\n")
|
|
append_text = append_text.strip()
|
|
|
|
num_prompts = len(prompt_lines)
|
|
|
|
if index < 0 or index >= num_prompts:
|
|
raise ValueError(f"Index {index} is out of range. Please provide an index between 0 and {num_prompts - 1}.")
|
|
|
|
selected_prompt = prompt_lines[index].strip()
|
|
|
|
if prepend_text:
|
|
selected_prompt = prepend_text + " " + selected_prompt
|
|
|
|
if append_text:
|
|
selected_prompt = selected_prompt + " " + append_text
|
|
|
|
return (selected_prompt,) |