diff --git a/TT_StoryCombiner.py b/TT_StoryCombiner.py new file mode 100644 index 0000000..9cc36ea --- /dev/null +++ b/TT_StoryCombiner.py @@ -0,0 +1,71 @@ +import random +from typing import List +import comfy.model_management as model_management + +class TT_StoryCombiner: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text1": ("STRING", {"multiline": True}), + "text2": ("STRING", {"multiline": True}), + "text3": ("STRING", {"multiline": True}), + "text4": ("STRING", {"multiline": True}), + "text5": ("STRING", {"multiline": True}), + "text6": ("STRING", {"multiline": True}), + "text7": ("STRING", {"multiline": True}), + "text8": ("STRING", {"multiline": True}), + "text9": ("STRING", {"multiline": True}), + "separator": ("STRING", {"default": ". "}), + "seed": ("INT", {"default": 0}), + "enhance_female_prompt": ("BOOLEAN", {"default": False}) + } + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "process" + CATEGORY = "TT_TextTools" + + def process(self, text1: str, text2: str, text3: str, text4: str, text5: str, text6: str, text7: str, text8: str, text9: str, separator: str, seed: int, enhance_female_prompt: bool) -> List[str]: + random.seed(seed) + + def get_random_line(text): + lines = [line.strip() for line in text.split("\n") if line.strip()] + return random.choice(lines) if lines else "" + + selected_lines = [ + get_random_line(text1), + get_random_line(text2), + get_random_line(text3), + get_random_line(text4), + get_random_line(text5), + get_random_line(text6), + get_random_line(text7), + get_random_line(text8), + get_random_line(text9) + ] + + filtered_lines = [line for line in selected_lines if line] + + result = separator.join(filtered_lines) + + if enhance_female_prompt: + result += separator + "large breasts. nipples under clothes women dress style." + + return (result,) + +def register_nodes(): + return {"TT_StoryCombiner": TT_StoryCombiner} + + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "TT_StoryCombiner": TT_StoryCombiner +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "TT_StoryCombiner": "TT_StoryCombiner" +} \ No newline at end of file diff --git a/TT_TextInput.py b/TT_TextInput.py new file mode 100644 index 0000000..8871ce8 --- /dev/null +++ b/TT_TextInput.py @@ -0,0 +1,17 @@ +import comfy.model_management + +class TT_TextInput: + @classmethod + def INPUT_TYPES(cls): + return {"required": {"text": ("STRING", {"multiline": True, "default": ""})}} + + RETURN_TYPES = ("STRING",) + FUNCTION = "process" + CATEGORY = "TT_TextTools" + + def process(self, text): + return (text,) + +# Register the node +NODE_CLASS_MAPPINGS = {"TT_TextInput": TT_TextInput} +NODE_DISPLAY_NAME_MAPPINGS = {"TT_TextInput": "TT_Text Input"} diff --git a/__init__.py b/__init__.py index d84d64c..e6e37f0 100644 --- a/__init__.py +++ b/__init__.py @@ -1,15 +1,21 @@ from .TT_FemaleClothes import TT_FemaleClothes from .TT_RandomPlacesOnEarth import TT_RandomPlacesOnEarth from .TT_CountryOfOrigin import TT_CountryOfOrigin +from .TT_StoryCombiner import TT_StoryCombiner +from .TT_TextInput import TT_TextInput NODE_CLASS_MAPPINGS = { "TT_FemaleClothes": TT_FemaleClothes, "TT_RandomPlacesOnEarth": TT_RandomPlacesOnEarth, "TT_CountryOfOrigin": TT_CountryOfOrigin, + "TT_StoryCombiner": TT_StoryCombiner, + "TT_TextInput": TT_TextInput, } NODE_DISPLAY_NAME_MAPPINGS = { "TT_FemaleClothes": "TT_FemaleClothes", "TT_RandomPlacesOnEarth": "TT_RandomPlacesOnEarth", "TT_CountryOfOrigin": "TT_CountryOfOrigin", + "TT_StoryCombiner": "TT_StoryCombiner", + "TT_TextInput": "TT_Text Input", } \ No newline at end of file