Add remove_empty_lines on easy promptLine

This commit is contained in:
yolain
2025-10-30 14:13:51 +08:00
parent 125b3a4905
commit 499ed4eafc
3 changed files with 11 additions and 2 deletions
+3
View File
@@ -250,6 +250,9 @@
},
"max_rows": {
"name": "max_rows"
},
"remove_empty_lines":{
"name": "remove_empty_lines"
}
},
"outputs": {
+3
View File
@@ -154,6 +154,9 @@
},
"max_rows": {
"name": "最大行数"
},
"remove_empty_lines":{
"name": "去除空行"
}
},
"outputs": {
+5 -2
View File
@@ -295,6 +295,7 @@ class promptLine:
"prompt": ("STRING", {"multiline": True, "default": "text"}),
"start_index": ("INT", {"default": 0, "min": 0, "max": 9999}),
"max_rows": ("INT", {"default": 1000, "min": 1, "max": 9999}),
"remove_empty_lines": ("BOOLEAN", {"default": True}),
},
"hidden":{
"workflow_prompt": "PROMPT", "my_unique_id": "UNIQUE_ID"
@@ -307,9 +308,11 @@ class promptLine:
FUNCTION = "generate_strings"
CATEGORY = "EasyUse/Prompt"
def generate_strings(self, prompt, start_index, max_rows, workflow_prompt=None, my_unique_id=None):
def generate_strings(self, prompt, start_index, max_rows, remove_empty_lines=True, workflow_prompt=None, my_unique_id=None):
lines = prompt.split('\n')
# lines = [zh_to_en([v])[0] if has_chinese(v) else v for v in lines if v]
if remove_empty_lines:
lines = [line for line in lines if line.strip()]
start_index = max(0, min(start_index, len(lines) - 1))