 Nodes can now chain together, which lets you build lovely, natural sentence fragments. There's nothing particularly fancy or special going on here, it doesn't handle tokenisation in any particular way, it simply lets you structure your inputs in a nicer format if you feel so inclined. :)
29 lines
676 B
Python
29 lines
676 B
Python
class BetterString:
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"optional": {
|
|
"chain": ("STRING", {"multiline": False, "forceInput": True, "defaultInput": True}),
|
|
},
|
|
"required": {
|
|
"string": ("STRING", {"multiline": True}),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("STRING",)
|
|
CATEGORY = "Better Things 💡"
|
|
|
|
def action(self, string, chain="", ):
|
|
if not chain.strip():
|
|
return (string,)
|
|
|
|
chain = chain.rstrip()
|
|
if chain[-1] != ",":
|
|
chain += ","
|
|
|
|
chain += " "
|
|
|
|
return (chain + string,)
|
|
|
|
FUNCTION = action.__name__
|