Update List Concat Node to allow combination of arbitrary number of list elements

This commit is contained in:
zer0gear
2024-11-11 13:32:20 -06:00
parent 208d93a9f7
commit efaef3cfa6
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -4,7 +4,7 @@ class ListConcatNode:
return {
"required": {
"input_list": ("*", {"tooltip": "The list of strings to concatenate"}),
"combine_last_three_items": (["FALSE", "TRUE"], {"tooltip": "If TRUE, the last three items in the list will be combined before concatenating, useful for when using LORAs"}),
"combine_last_x_items": ("INT", {"default": 1, "min": 1, "max": 999, "tooltip": "If greater than 1, the last X items in the list will be combined before concatenating. Useful for correcting unnecessary separators."}),
"separator": ("STRING", {"default": " BREAK ", "tooltip": "The separator to use when concatenating the list"}),
}
}
@@ -17,8 +17,8 @@ class ListConcatNode:
INPUT_IS_LIST = True
FUNCTION = "concat_list_with_separator"
CATEGORY = "text utility"
def concat_list_with_separator(self, input_list, combine_last_three_items, separator):
# If combine_last_three_items is TRUE, combine the last three items in the list before concating
if combine_last_three_items[0] == "TRUE":
input_list[-3:] = ["".join(input_list[-3:])]
def concat_list_with_separator(self, input_list, combine_last_x_items, separator):
# If combine_last_x_items is greater than 1, combine the last X items in the list
if combine_last_x_items[0] > 1:
input_list[-combine_last_x_items[0]:] = ["".join(input_list[-combine_last_x_items[0]:])]
return (separator[0].join(input_list),)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "zer0gear-comfy-utilities"
description = "Nodes: ListConcat with custom separator, Multiline String"
version = "1.1.0" # Custom Node version. Must be semantically versioned.
version = "2.0.0" # Custom Node version. Must be semantically versioned.
license = { file = "LICENSE.txt" }
dependencies = [] # Filled in from requirements.txt