From 6e3b4178ac93d887f1b363a8d46542543c4a5561 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Thu, 27 Mar 2025 16:10:50 +0800 Subject: [PATCH] Enhance LoraStacker to return active LoRAs in stack_loras method - Updated RETURN_TYPES and RETURN_NAMES to include active LoRAs. - Introduced active_loras list to track active LoRAs and their strengths. - Formatted active_loras for return as a string in the format . --- py/nodes/lora_stacker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/py/nodes/lora_stacker.py b/py/nodes/lora_stacker.py index b264bd27..ed6662cb 100644 --- a/py/nodes/lora_stacker.py +++ b/py/nodes/lora_stacker.py @@ -26,8 +26,8 @@ class LoraStacker: "optional": FlexibleOptionalInputType(any_type), } - RETURN_TYPES = ("LORA_STACK", IO.STRING) - RETURN_NAMES = ("LORA_STACK", "trigger_words") + RETURN_TYPES = ("LORA_STACK", IO.STRING, IO.STRING) + RETURN_NAMES = ("LORA_STACK", "trigger_words", "active_loras") FUNCTION = "stack_loras" async def get_lora_info(self, lora_name): @@ -75,6 +75,7 @@ class LoraStacker: def stack_loras(self, text, **kwargs): """Stacks multiple LoRAs based on the kwargs input without loading them.""" stack = [] + active_loras = [] all_trigger_words = [] # Process existing lora_stack if available @@ -103,11 +104,15 @@ class LoraStacker: # Add to stack without loading # replace '/' with os.sep to avoid different OS path format stack.append((lora_path.replace('/', os.sep), model_strength, clip_strength)) + active_loras.append((lora_name, model_strength)) # Add trigger words to collection all_trigger_words.extend(trigger_words) # use ',, ' to separate trigger words for group mode trigger_words_text = ",, ".join(all_trigger_words) if all_trigger_words else "" + # Format active_loras as separated by spaces + active_loras_text = " ".join([f"" + for name, strength in active_loras]) - return (stack, trigger_words_text) + return (stack, trigger_words_text, active_loras_text)