Fixed optional params
This commit is contained in:
+14
-1
@@ -5716,6 +5716,7 @@ function imageInferenceSettingsStructuredPromptToggleHandler(node) {
|
||||
|
||||
const useElementsJsonWidget = node.widgets.find((w) => w && w.name === "useElementsJson");
|
||||
const elementsJsonWidget = node.widgets.find((w) => w && w.name === "elementsJson");
|
||||
const elementSlotRefreshers = [];
|
||||
if (useElementsJsonWidget && elementsJsonWidget) {
|
||||
toggleWidgetState(useElementsJsonWidget, elementsJsonWidget, "elementsJson");
|
||||
}
|
||||
@@ -5730,13 +5731,16 @@ function imageInferenceSettingsStructuredPromptToggleHandler(node) {
|
||||
if (!useW) return;
|
||||
|
||||
function toggleSlot() {
|
||||
const enabled = useW.value === true;
|
||||
const jsonMode = useElementsJsonWidget?.value === true;
|
||||
toggleWidgetEnabled(useW, !jsonMode, node);
|
||||
const enabled = !jsonMode && useW.value === true;
|
||||
[typeW, descW, textW, bboxW, paletteW].forEach((w) => {
|
||||
if (w) toggleWidgetEnabled(w, enabled, node);
|
||||
});
|
||||
node.setDirtyCanvas(true);
|
||||
}
|
||||
|
||||
elementSlotRefreshers.push(toggleSlot);
|
||||
appendWidgetCB(useW, () => setTimeout(toggleSlot, 50));
|
||||
setTimeout(toggleSlot, 100);
|
||||
}
|
||||
@@ -5744,6 +5748,15 @@ function imageInferenceSettingsStructuredPromptToggleHandler(node) {
|
||||
for (let i = 1; i <= 8; i++) {
|
||||
bindElementSlot(i);
|
||||
}
|
||||
|
||||
if (useElementsJsonWidget) {
|
||||
function refreshElementSlotsForJsonMode() {
|
||||
elementSlotRefreshers.forEach((refresh) => refresh());
|
||||
node.setDirtyCanvas(true);
|
||||
}
|
||||
appendWidgetCB(useElementsJsonWidget, () => setTimeout(refreshElementSlotsForJsonMode, 50));
|
||||
setTimeout(refreshElementSlotsForJsonMode, 100);
|
||||
}
|
||||
}
|
||||
|
||||
function syncProviderSettingsToggleHandler(syncNode) {
|
||||
|
||||
@@ -225,7 +225,21 @@ class txt2img:
|
||||
def VALIDATE_INPUTS(cls, **kwargs):
|
||||
positivePrompt = kwargs.get("positivePrompt", "")
|
||||
negativePrompt = kwargs.get("negativePrompt", "")
|
||||
|
||||
settings = kwargs.get("settings")
|
||||
|
||||
structured_prompt = None
|
||||
if isinstance(settings, dict):
|
||||
structured_prompt = settings.get("structuredPrompt")
|
||||
has_structured_prompt = (
|
||||
isinstance(structured_prompt, dict) and len(structured_prompt) > 0
|
||||
)
|
||||
has_positive_prompt = bool(positivePrompt and str(positivePrompt).strip())
|
||||
if has_structured_prompt and has_positive_prompt:
|
||||
return (
|
||||
"settings.structuredPrompt and positivePrompt are mutually exclusive. "
|
||||
"Clear positivePrompt or disconnect Structured Prompt from Settings."
|
||||
)
|
||||
|
||||
# Only validate positivePrompt length if it's provided
|
||||
if positivePrompt and len(positivePrompt) > 10000:
|
||||
return "Positive Prompt is too long. Maximum length is 10000 characters."
|
||||
|
||||
@@ -17,11 +17,6 @@ class RunwareImageInferenceSettingsStructuredPrompt:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
optional: Dict[str, tuple] = {
|
||||
"high_level_description": ("STRING", {
|
||||
"multiline": True,
|
||||
"default": "",
|
||||
"tooltip": "Global scene summary (required).",
|
||||
}),
|
||||
"background": ("STRING", {
|
||||
"multiline": True,
|
||||
"default": "",
|
||||
@@ -81,7 +76,14 @@ class RunwareImageInferenceSettingsStructuredPrompt:
|
||||
"tooltip": f"Element {i} optional hex colours, comma-separated (e.g. #1F3B26,#7A5A2F).",
|
||||
})
|
||||
|
||||
return {"required": {}, "optional": optional}
|
||||
required = {
|
||||
"high_level_description": ("STRING", {
|
||||
"multiline": True,
|
||||
"default": "",
|
||||
"tooltip": "Global scene summary (required).",
|
||||
}),
|
||||
}
|
||||
return {"required": required, "optional": optional}
|
||||
|
||||
RETURN_TYPES = ("RUNWAREIMAGEINFERENCESTRUCTUREDPROMPT",)
|
||||
RETURN_NAMES = ("structuredPrompt",)
|
||||
|
||||
Reference in New Issue
Block a user