diff --git a/comfy-nodes/comfy_std_output.py b/comfy-nodes/comfy_std_output.py new file mode 100644 index 0000000..8b100b0 --- /dev/null +++ b/comfy-nodes/comfy_std_output.py @@ -0,0 +1,45 @@ +import json + + +class AnyType(str): + """A special class that is always equal in not equal comparisons. Credit to pythongosssss""" + + def __ne__(self, __value: object) -> bool: + return False + + +any = AnyType("*") + + +class ComfyDeployStdOutputAny: + @classmethod + def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring + return { + "required": { + "source": (any, {}), # Use "*" to accept any input type + }, + } + + CATEGORY = "output" + RETURN_TYPES = () + FUNCTION = "run" + OUTPUT_NODE = True + + def run(self, source=None): + value = "None" + if source is not None: + try: + value = json.dumps(source) + except Exception: + try: + value = str(source) + except Exception: + value = "source exists, but could not be serialized." + + return {"ui": {"text": (value,)}} + + +NODE_CLASS_MAPPINGS = {"ComfyDeployStdOutputAny": ComfyDeployStdOutputAny} +NODE_DISPLAY_NAME_MAPPINGS = { + "ComfyDeployStdOutputAny": "Standard Any Output (ComfyDeploy)" +}