mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-30 00:00:26 +08:00
Add the MULTIPLE_NODE = True attribute to the node to enable multiple input lines with the ability to have empty input connections.
Currently, each input interface must be connected to a node, but I want to implement the function of merging multiple texts and allow input nodes to remain unconnected. For example, the node can merge up to 5 texts, but it can still execute when the user only connects two input nodes.
This commit is contained in:
parent
92eca60ec9
commit
38f0c191f2
21
execution.py
21
execution.py
@ -64,12 +64,15 @@ def recursive_execute(server, prompt, outputs, current_item, extra_data={}):
|
||||
obj = class_def()
|
||||
|
||||
nodes.before_node_execution()
|
||||
outputs[unique_id] = getattr(obj, obj.FUNCTION)(**input_data_all)
|
||||
if "ui" in outputs[unique_id]:
|
||||
if server.client_id is not None:
|
||||
server.send_sync("executed", { "node": unique_id, "output": outputs[unique_id]["ui"] }, server.client_id)
|
||||
if "result" in outputs[unique_id]:
|
||||
outputs[unique_id] = outputs[unique_id]["result"]
|
||||
try:
|
||||
outputs[unique_id] = getattr(obj, obj.FUNCTION)(**input_data_all)
|
||||
if "ui" in outputs[unique_id]:
|
||||
if server.client_id is not None:
|
||||
server.send_sync("executed", {"node": unique_id, "output": outputs[unique_id]["ui"]}, server.client_id)
|
||||
if "result" in outputs[unique_id]:
|
||||
outputs[unique_id] = outputs[unique_id]["result"]
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return executed + [unique_id]
|
||||
|
||||
def recursive_will_execute(prompt, outputs, current_item):
|
||||
@ -213,12 +216,14 @@ def validate_inputs(prompt, item):
|
||||
inputs = prompt[unique_id]['inputs']
|
||||
class_type = prompt[unique_id]['class_type']
|
||||
obj_class = nodes.NODE_CLASS_MAPPINGS[class_type]
|
||||
|
||||
class_inputs = obj_class.INPUT_TYPES()
|
||||
required_inputs = class_inputs['required']
|
||||
for x in required_inputs:
|
||||
if x not in inputs:
|
||||
return (False, "Required input is missing. {}, {}".format(class_type, x))
|
||||
if obj_class.MULTIPLE_NODE != True:
|
||||
return (False, "Required input is missing. {}, {}".format(class_type, x))
|
||||
else:
|
||||
return (True, "")
|
||||
val = inputs[x]
|
||||
info = required_inputs[x]
|
||||
type_input = info[0]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user