Added support for Moodboards
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
"""
|
||||
Runware Image Inference Settings Moodboards
|
||||
Builds settings.moodboards: list of { "id": "<uuid>", "strength": <number> }.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
|
||||
class RunwareImageInferenceSettingsMoodboards:
|
||||
"""Build moodboards list for image inference settings."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"id": ("STRING", {
|
||||
"default": "",
|
||||
"tooltip": "Moodboard UUID (settings.moodboards[].id).",
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
"useStrength": ("BOOLEAN", {
|
||||
"default": False,
|
||||
"label_on": "Enabled",
|
||||
"label_off": "Disabled",
|
||||
"tooltip": "Include strength in moodboards entry.",
|
||||
}),
|
||||
"strength": ("FLOAT", {
|
||||
"default": 0.35,
|
||||
"min": -0.5,
|
||||
"max": 1.5,
|
||||
"step": 0.01,
|
||||
"tooltip": "Moodboard strength (-0.5 to 1.5). Only used when useStrength is enabled.",
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("RUNWAREIMAGEINFERENCEMOODBOARDS",)
|
||||
RETURN_NAMES = ("moodboards",)
|
||||
FUNCTION = "build_moodboards"
|
||||
CATEGORY = "Runware"
|
||||
DESCRIPTION = (
|
||||
"Build settings.moodboards for image inference settings. "
|
||||
"Outputs one-element array with required id and optional strength."
|
||||
)
|
||||
|
||||
def build_moodboards(self, **kwargs) -> Tuple[List[Dict[str, Any]]]:
|
||||
moodboard_id = str(kwargs.get("id") or "").strip()
|
||||
if not moodboard_id:
|
||||
return ([],)
|
||||
|
||||
entry: Dict[str, Any] = {"id": moodboard_id}
|
||||
if kwargs.get("useStrength", False):
|
||||
entry["strength"] = float(kwargs.get("strength", 0.35))
|
||||
|
||||
return ([entry],)
|
||||
"""
|
||||
Runware Image Inference Settings Moodboards
|
||||
Builds settings.moodboards: list of { "id": "<uuid>", "strength": <number> }.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
|
||||
class RunwareImageInferenceSettingsMoodboards:
|
||||
"""Build moodboards list for image inference settings."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"id": ("STRING", {
|
||||
"default": "",
|
||||
"tooltip": "Moodboard UUID (settings.moodboards[].id).",
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
"useStrength": ("BOOLEAN", {
|
||||
"default": False,
|
||||
"label_on": "Enabled",
|
||||
"label_off": "Disabled",
|
||||
"tooltip": "Include strength in moodboards entry.",
|
||||
}),
|
||||
"strength": ("FLOAT", {
|
||||
"default": 0.35,
|
||||
"min": -0.5,
|
||||
"max": 1.5,
|
||||
"step": 0.01,
|
||||
"tooltip": "Moodboard strength (-0.5 to 1.5). Only used when 'Use Strength' is enabled.",
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("RUNWAREIMAGEINFERENCEMOODBOARDS",)
|
||||
RETURN_NAMES = ("moodboards",)
|
||||
FUNCTION = "build_moodboards"
|
||||
CATEGORY = "Runware"
|
||||
DESCRIPTION = (
|
||||
"Build settings.moodboards for image inference settings. "
|
||||
"Outputs one-element array with required id and optional strength."
|
||||
)
|
||||
|
||||
def build_moodboards(self, **kwargs) -> Tuple[List[Dict[str, Any]]]:
|
||||
moodboard_id = str(kwargs.get("id") or "").strip()
|
||||
if not moodboard_id:
|
||||
return ([],)
|
||||
|
||||
entry: Dict[str, Any] = {"id": moodboard_id}
|
||||
if kwargs.get("useStrength", False):
|
||||
entry["strength"] = float(kwargs.get("strength", 0.35))
|
||||
|
||||
return ([entry],)
|
||||
+10
-2
@@ -3,7 +3,8 @@ Runware Image Inference Settings (registered as Runware Settings for workflow co
|
||||
Provides settings for image generation including temperature, systemPrompt, topP, layers,
|
||||
quality, background, style, search, promptExtend, editRegions, thinking (boolean),
|
||||
thinkingLevel (high/medium/low), sequential, renderingSpeed (TURBO/DEFAULT/QUALITY),
|
||||
magicPrompt (AUTO/ON/OFF), autoCrop, dilatePixels, creativity (raw/low/medium/high), and colorPalette
|
||||
magicPrompt (AUTO/ON/OFF), autoCrop, dilatePixels, creativity (raw/low/medium/high), colorPalette,
|
||||
and moodboards
|
||||
(from Runware Image Inference Settings Color Palette).
|
||||
"""
|
||||
|
||||
@@ -121,6 +122,9 @@ class RunwareSettings:
|
||||
"colorPalette": ("RUNWAREIMAGEINFERENCECOLORPALETTE", {
|
||||
"tooltip": "Connect Runware Image Inference Color Palette. When the palette node outputs at least one swatch, it is merged into settings.colorPalette.",
|
||||
}),
|
||||
"moodboards": ("RUNWAREIMAGEINFERENCEMOODBOARDS", {
|
||||
"tooltip": "Connect Runware Image Inference Settings Moodboards. When connected with at least one entry, it is merged into settings.moodboards.",
|
||||
}),
|
||||
"useThinkingLevel": ("BOOLEAN", {
|
||||
"tooltip": "Enable to include thinkingLevel (string) in settings.",
|
||||
"default": False,
|
||||
@@ -211,7 +215,8 @@ class RunwareSettings:
|
||||
DESCRIPTION = (
|
||||
"Configure general settings for image generation: temperature, system prompt, top-p, layers, quality, background, style, search, "
|
||||
"promptExtend, editRegions (JSON), thinking (boolean), thinkingLevel (high/medium/low), sequential, "
|
||||
"renderingSpeed (TURBO/DEFAULT/QUALITY), magicPrompt (AUTO/ON/OFF), autoCrop, dilatePixels, creativity (raw/low/medium/high), and optional colorPalette from the Color Palette node."
|
||||
"renderingSpeed (TURBO/DEFAULT/QUALITY), magicPrompt (AUTO/ON/OFF), autoCrop, dilatePixels, "
|
||||
"creativity (raw/low/medium/high), and optional colorPalette and moodboards from dedicated settings nodes."
|
||||
)
|
||||
|
||||
def createSettings(self, **kwargs) -> tuple[Dict[str, Any]]:
|
||||
@@ -300,6 +305,9 @@ class RunwareSettings:
|
||||
palette: Optional[List[Dict[str, Any]]] = kwargs.get("colorPalette")
|
||||
if palette is not None and isinstance(palette, list) and len(palette) > 0:
|
||||
settings["colorPalette"] = palette
|
||||
moodboards: Optional[List[Dict[str, Any]]] = kwargs.get("moodboards")
|
||||
if moodboards is not None and isinstance(moodboards, list) and len(moodboards) > 0:
|
||||
settings["moodboards"] = moodboards
|
||||
|
||||
if useRenderingSpeed:
|
||||
settings["renderingSpeed"] = str(renderingSpeed)
|
||||
|
||||
@@ -158,7 +158,7 @@ def getCustomEndpoint():
|
||||
custom_endpoint = os.getenv("RUNWARE_CUSTOM_ENDPOINT")
|
||||
if custom_endpoint and isinstance(custom_endpoint, str):
|
||||
return custom_endpoint
|
||||
return "https://api.runware.ai/v1"
|
||||
return "https://api.runware.dev/v1"
|
||||
|
||||
SESSION_TIMEOUT = getTimeout()
|
||||
RUNWARE_API_KEY = getAPIKey()
|
||||
|
||||
Reference in New Issue
Block a user