feat(trigger): add optional strength adjustment for trigger words

Add `allow_strength_adjustment` parameter to enable mouse wheel adjustment of trigger word strengths. When enabled, strength values are preserved and can be modified interactively. Also improves trigger word parsing by handling whitespace more consistently and adding debug logging for trigger data inspection.
This commit is contained in:
Will Miao
2025-11-09 22:24:23 +08:00
parent f81ff2efe9
commit 4dd8ce778e
4 changed files with 265 additions and 117 deletions

View File

@@ -0,0 +1,26 @@
from py.nodes.trigger_word_toggle import TriggerWordToggle
def test_group_mode_preserves_parenthesized_groups():
node = TriggerWordToggle()
trigger_data = [
{'text': 'flat color, dark theme', 'active': True, 'strength': None, 'highlighted': False},
{'text': '(a, really, long, test, trigger, word:1.06)', 'active': True, 'strength': 1.06, 'highlighted': False},
{'text': '(sinozick style:0.94)', 'active': True, 'strength': 0.94, 'highlighted': False},
]
original_message = (
"flat color, dark theme, (a, really, long, test, trigger, word:1.06), "
"(sinozick style:0.94)"
)
filtered, = node.process_trigger_words(
id="node",
group_mode=True,
default_active=True,
allow_strength_adjustment=False,
orinalMessage=original_message,
toggle_trigger_words=trigger_data,
)
assert filtered == original_message