mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-26 19:19:53 +00:00
add support for kwargs inputs to allow arbitrary inputs from frontend (#12063)
used to output selected combo index Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
This commit is contained in:
@@ -1383,6 +1383,8 @@ class Schema:
|
|||||||
"""Flags a node as not idempotent; when True, the node will run and not reuse the cached outputs when identical inputs are provided on a different node in the graph."""
|
"""Flags a node as not idempotent; when True, the node will run and not reuse the cached outputs when identical inputs are provided on a different node in the graph."""
|
||||||
enable_expand: bool=False
|
enable_expand: bool=False
|
||||||
"""Flags a node as expandable, allowing NodeOutput to include 'expand' property."""
|
"""Flags a node as expandable, allowing NodeOutput to include 'expand' property."""
|
||||||
|
accept_all_inputs: bool=False
|
||||||
|
"""When True, all inputs from the prompt will be passed to the node as kwargs, even if not defined in the schema."""
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
'''Validate the schema:
|
'''Validate the schema:
|
||||||
@@ -1853,6 +1855,14 @@ class _ComfyNodeBaseInternal(_ComfyNodeInternal):
|
|||||||
cls.GET_SCHEMA()
|
cls.GET_SCHEMA()
|
||||||
return cls._NOT_IDEMPOTENT
|
return cls._NOT_IDEMPOTENT
|
||||||
|
|
||||||
|
_ACCEPT_ALL_INPUTS = None
|
||||||
|
@final
|
||||||
|
@classproperty
|
||||||
|
def ACCEPT_ALL_INPUTS(cls): # noqa
|
||||||
|
if cls._ACCEPT_ALL_INPUTS is None:
|
||||||
|
cls.GET_SCHEMA()
|
||||||
|
return cls._ACCEPT_ALL_INPUTS
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls) -> dict[str, dict]:
|
def INPUT_TYPES(cls) -> dict[str, dict]:
|
||||||
@@ -1891,6 +1901,8 @@ class _ComfyNodeBaseInternal(_ComfyNodeInternal):
|
|||||||
cls._INPUT_IS_LIST = schema.is_input_list
|
cls._INPUT_IS_LIST = schema.is_input_list
|
||||||
if cls._NOT_IDEMPOTENT is None:
|
if cls._NOT_IDEMPOTENT is None:
|
||||||
cls._NOT_IDEMPOTENT = schema.not_idempotent
|
cls._NOT_IDEMPOTENT = schema.not_idempotent
|
||||||
|
if cls._ACCEPT_ALL_INPUTS is None:
|
||||||
|
cls._ACCEPT_ALL_INPUTS = schema.accept_all_inputs
|
||||||
|
|
||||||
if cls._RETURN_TYPES is None:
|
if cls._RETURN_TYPES is None:
|
||||||
output = []
|
output = []
|
||||||
|
|||||||
@@ -104,19 +104,23 @@ class CustomComboNode(io.ComfyNode):
|
|||||||
category="utils",
|
category="utils",
|
||||||
is_experimental=True,
|
is_experimental=True,
|
||||||
inputs=[io.Combo.Input("choice", options=[])],
|
inputs=[io.Combo.Input("choice", options=[])],
|
||||||
outputs=[io.String.Output()]
|
outputs=[
|
||||||
|
io.String.Output(display_name="STRING"),
|
||||||
|
io.Int.Output(display_name="INDEX"),
|
||||||
|
],
|
||||||
|
accept_all_inputs=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_inputs(cls, choice: io.Combo.Type) -> bool:
|
def validate_inputs(cls, choice: io.Combo.Type, index: int = 0, **kwargs) -> bool:
|
||||||
# NOTE: DO NOT DO THIS unless you want to skip validation entirely on the node's inputs.
|
# NOTE: DO NOT DO THIS unless you want to skip validation entirely on the node's inputs.
|
||||||
# I am doing that here because the widgets (besides the combo dropdown) on this node are fully frontend defined.
|
# I am doing that here because the widgets (besides the combo dropdown) on this node are fully frontend defined.
|
||||||
# I need to skip checking that the chosen combo option is in the options list, since those are defined by the user.
|
# I need to skip checking that the chosen combo option is in the options list, since those are defined by the user.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, choice: io.Combo.Type) -> io.NodeOutput:
|
def execute(cls, choice: io.Combo.Type, index: int = 0, **kwargs) -> io.NodeOutput:
|
||||||
return io.NodeOutput(choice)
|
return io.NodeOutput(choice, index)
|
||||||
|
|
||||||
|
|
||||||
class DCTestNode(io.ComfyNode):
|
class DCTestNode(io.ComfyNode):
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ def get_input_data(inputs, class_def, unique_id, execution_list=None, dynprompt=
|
|||||||
continue
|
continue
|
||||||
obj = cached.outputs[output_index]
|
obj = cached.outputs[output_index]
|
||||||
input_data_all[x] = obj
|
input_data_all[x] = obj
|
||||||
elif input_category is not None:
|
elif input_category is not None or (is_v3 and class_def.ACCEPT_ALL_INPUTS):
|
||||||
input_data_all[x] = [input_data]
|
input_data_all[x] = [input_data]
|
||||||
|
|
||||||
if is_v3:
|
if is_v3:
|
||||||
|
|||||||
Reference in New Issue
Block a user