fix(randomizer): Initialize RANDOMIZER_CONFIG widget with default config

Initialize internalValue with default RandomizerConfig object instead of
undefined to prevent frontend from sending empty string to backend when
widget is first created.

This fixes the 'str' object has no attribute 'get' error that occurred
when running a newly created Lora Randomizer node before any user
interaction.

Fixes #4
This commit is contained in:
Will Miao
2026-02-23 14:25:55 +08:00
parent 26b139884c
commit ec5fd923ba
3 changed files with 34 additions and 3 deletions

View File

@@ -147,7 +147,23 @@ function createLoraRandomizerWidget(node) {
forwardMiddleMouseToCanvas(container)
let internalValue: RandomizerConfig | undefined
// Initialize with default config to avoid sending undefined/empty string to backend
const defaultConfig: RandomizerConfig = {
count_mode: 'range',
count_fixed: 3,
count_min: 2,
count_max: 5,
model_strength_min: 0.0,
model_strength_max: 1.0,
use_same_clip_strength: true,
clip_strength_min: 0.0,
clip_strength_max: 1.0,
roll_mode: 'fixed',
use_recommended_strength: false,
recommended_strength_scale_min: 0.5,
recommended_strength_scale_max: 1.0,
}
let internalValue: RandomizerConfig = defaultConfig
const widget = node.addDOMWidget(
'randomizer_config',

View File

@@ -14695,7 +14695,22 @@ function createLoraRandomizerWidget(node) {
container.style.flexDirection = "column";
container.style.overflow = "hidden";
forwardMiddleMouseToCanvas(container);
let internalValue;
const defaultConfig = {
count_mode: "range",
count_fixed: 3,
count_min: 2,
count_max: 5,
model_strength_min: 0,
model_strength_max: 1,
use_same_clip_strength: true,
clip_strength_min: 0,
clip_strength_max: 1,
roll_mode: "fixed",
use_recommended_strength: false,
recommended_strength_scale_min: 0.5,
recommended_strength_scale_max: 1
};
let internalValue = defaultConfig;
const widget = node.addDOMWidget(
"randomizer_config",
"RANDOMIZER_CONFIG",

File diff suppressed because one or more lines are too long