checkpoint

This commit is contained in:
Will Miao
2025-03-02 09:21:01 +08:00
parent 002823c6cf
commit 1c329ac6ca
6 changed files with 144 additions and 108 deletions

View File

@@ -1,6 +1,6 @@
import json
from server import PromptServer # type: ignore
from .utils import FlexibleOptionalInputType, any_type
import json
class TriggerWordToggle:
NAME = "TriggerWord Toggle (LoraManager)"
@@ -29,13 +29,19 @@ class TriggerWordToggle:
"id": id,
"message": trigger_words
})
print(f"kwargs: {kwargs}")
filtered_triggers = trigger_words
if 'hidden_trigger_words' in kwargs:
if 'toggle_trigger_words' in kwargs:
try:
# Parse the hidden trigger words JSON
trigger_data = json.loads(kwargs['hidden_trigger_words']) if isinstance(kwargs['hidden_trigger_words'], str) else kwargs['hidden_trigger_words']
# Get trigger word toggle data
trigger_data = kwargs['toggle_trigger_words']
# Convert to list if it's a JSON string
if isinstance(trigger_data, str):
trigger_data = json.loads(trigger_data)
# Create dictionaries to track active state of words
active_state = {item['text']: item.get('active', False) for item in trigger_data}
@@ -43,7 +49,7 @@ class TriggerWordToggle:
# Split original trigger words
original_words = [word.strip() for word in trigger_words.split(',')]
# Filter words: keep those not in hidden_trigger_words or those that are active
# Filter words: keep those not in toggle_trigger_words or those that are active
filtered_words = [word for word in original_words if word not in active_state or active_state[word]]
# Join them in the same format as input
@@ -54,8 +60,5 @@ class TriggerWordToggle:
except Exception as e:
print(f"Error processing trigger words: {e}")
for key, value in kwargs.items():
print(f"{key}: {value}")
return (filtered_triggers,)