From 86b33d097488e2c08c13b9ebca0550f554538a0e Mon Sep 17 00:00:00 2001 From: Teddy Xiong Date: Thu, 26 Mar 2026 04:49:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20batch=20text=20out?= =?UTF-8?q?put?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsyncOutput.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ __init__.py | 4 +++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/AsyncOutput.py b/AsyncOutput.py index 8ff778e..fc4f893 100644 --- a/AsyncOutput.py +++ b/AsyncOutput.py @@ -23,6 +23,7 @@ MAIN_CATEGORY = "AsyncOutput" ASYNC_OUTPUT_STORAGE_DATA = {} ASYNC_OUTPUT_COUNTER = {} +ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT = {} class AsyncOutputCollectionNode: def __init__(self): @@ -245,4 +246,58 @@ support list: return (result, ) +class AsyncOutputMultiLineTextWithBatchNode: + def __init__(self): + pass + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "touch": ("BOOLEAN", { "forceInput": True }), + "eof_size": ("INT", { "forceInput": True }), + "text": ("STRING", { "multiline": True }), + "remove_words": ("LIST", { "forceInput": True }), + "delimiter": ("STRING", { "multiline": False, "default": "\n" }), + "skip_empty": ("BOOLEAN", { "default": True }), + }, + "hidden": { + "unique_id": "UNIQUE_ID" + } + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("text_line",) + CATEGORY = f'{MAIN_CATEGORY}/WorkFlowTool' + FUNCTION = "batch_text_yield" + + def batch_text_yield(self, touch, eof_size, text, remove_words, delimiter="\n", skip_empty=True, unique_id=0): + global ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT + + if unique_id not in ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT: + ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT[unique_id] = 0 + + current_line_index = ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT[unique_id] + ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT[unique_id] += 1 + + prompts = text.split(delimiter) + + if skip_empty: + prompts = [p.strip() for p in prompts if p.strip()] + else: + prompts = [p.strip() for p in prompts] + + + if ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT[unique_id] == eof_size: + del ASYNC_OUTPUT_MULTI_LINE_TEXT_YIELD_ID_DECT[unique_id] + + current_line_promts = prompts[current_line_index] + for word in remove_words: + if isinstance(word, str): + current_line_promts = current_line_promts.replace(word, "") + + return (current_line_promts,) + + @classmethod + def IS_CHANGED(s, touch, eof_size, text, remove_words, delimiter="\n", skip_empty=True, unique_id=0): + return float('nan') diff --git a/__init__.py b/__init__.py index a4148ae..8b4ff96 100644 --- a/__init__.py +++ b/__init__.py @@ -11,7 +11,8 @@ NODE_CLASS_MAPPINGS = { "AsyncOutputCollect": AsyncOutput.AsyncOutputCollectionNode, "AsyncOutputEmitter": AsyncOutput.AsyncOutputEmitterNode, "AsyncOutputCallback": AsyncOutput.AsyncOutputCallbackNode, - "AsyncOutputConvertStringListToString": AsyncOutput.AsyncOutputConvertStringListToStringNode + "AsyncOutputConvertStringListToString": AsyncOutput.AsyncOutputConvertStringListToStringNode, + "AsyncOutputMultiLineTextWithBatch": AsyncOutput.AsyncOutputMultiLineTextWithBatchNode, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -19,6 +20,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "AsyncOutputEmitter": "Conditions", "AsyncOutputCallback": "Output", "AsyncOutputConvertStringListToString": "String List To String", + "AsyncOutputMultiLineTextWithBatch": "Batch Text Yield With Batch" } __all__ = [