Files
Runware-ComfyUI-Runware/modules/safetyInputs.py
T
Sirshendu Ganguly 056ade0661 Refactor: Use librosa instead of torchaudio, Add dedicated handlers for all use parameters and fix widget ordering
- Use librosa instead of torchaudio for mediaStorage
- Created dedicated toggle handlers for Image Inference, Video Inference, Upscaler, Audio Inference, Accelerator Options, Bytedance Provider Settings, and OpenAI Provider Settings
- Fixed Audio Inference widget ordering (use parameters now appear before their corresponding parameters)
- All handlers use the same proven pattern from videoInferenceDimensionsHandler
- Improved widget disabling/enabling functionality across all nodes
2025-11-05 22:31:15 -05:00

72 lines
2.5 KiB
Python

from typing import Optional, Dict, Any
class safetyInputs:
"""Runware Safety Inputs Node for configuring safety and content moderation settings"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {},
"optional": {
"mode": (["none", "fast", "full"], {
"tooltip": "Safety moderation mode: none (disable), fast (quick check), or full (comprehensive check).",
"default": "none",
}),
"tolerance": ("BOOLEAN", {
"tooltip": "Safety tolerance setting for content moderation.",
"default": None,
"label_on": "Enabled",
"label_off": "Disabled",
}),
"checkInputs": ("BOOLEAN", {
"tooltip": "Enable checking of input content for safety violations.",
"default": None,
"label_on": "Enabled",
"label_off": "Disabled",
}),
"checkContent": ("BOOLEAN", {
"tooltip": "Enable checking of generated content for safety violations.",
"default": None,
"label_on": "Enabled",
"label_off": "Disabled",
}),
}
}
RETURN_TYPES = ("RUNWARESAFETYINPUTS",)
RETURN_NAMES = ("Safety Inputs",)
FUNCTION = "createSafetyInputs"
CATEGORY = "Runware"
DESCRIPTION = "Configure safety and content moderation settings for Runware tasks."
def createSafetyInputs(self, **kwargs) -> tuple[Dict[str, Any]]:
"""Create safety inputs dictionary"""
mode = kwargs.get("mode", None)
tolerance = kwargs.get("tolerance", None)
checkInputs = kwargs.get("checkInputs", None)
checkContent = kwargs.get("checkContent", None)
safetyInputs = {}
if mode is not None:
safetyInputs["mode"] = mode
if tolerance is not None:
safetyInputs["tolerance"] = tolerance
if checkInputs is not None:
safetyInputs["checkInputs"] = checkInputs
if checkContent is not None:
safetyInputs["checkContent"] = checkContent
return (safetyInputs,)
# Node class mappings
NODE_CLASS_MAPPINGS = {
"RunwareSafetyInputs": safetyInputs,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"RunwareSafetyInputs": "Runware Safety Inputs",
}