Files
HaydenReeve-ComfyUI-Better-…/BetterString.py
T
Hayden Reeve 27dcb78e75 Added the ability to chain together multiple multiline string nodes (#4)
![image](https://github.com/user-attachments/assets/fb2841ec-f2ef-4802-acae-eb76697391be)

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. :)
2024-10-11 22:54:15 +08:00

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__