InvokeAI
InvokeAI copied to clipboard
experiment: allow Any as output type in nodes
Summary
Allow Any to be an output type for node fields. This introduces a major footgun, so we haven't enabled it.
It's safe for nodes to have Any type inputs, because that node knows up front that it could get literally anything as an input. The node knows it must handle literally anything and it is able to take that responsibility.
It is unsafe for nodes to have Any type outputs, because then every node must be able to handle literally anything as an input. It shifts the responsibility of dealing with untyped inputs to every node, instead of only the nodes that explicitly accept them.
This also encourages node authors to just slap Any on every output because that's way easier than actually defining types.
Ok, all that said, this does increase node power. For example, we can provide a flexible Switcher node (included in this PR). This node has 2 Any inputs and 1 Any output. A switch: bool input lets you choose between the two inputs.
If we want to accept the change in this PR, we could add a setting the workflow editor to make this opt-in:
- Besides
IterateandCollectnodes, which are special cases, hide all nodes withAnyoutputs. - Besides
IterateandCollectnodes, which are special cases, do not allow nodes withAnyoutputs to pass validation.
Another way to reduce footguns would be to special-case nodes like the Switcher, making the Any type function more like a generic. The type would be inferred from one of the inputs, and its output would be treated as the inferred type. Obviously this reduces the flexibility of the node.
I think I'm OK with this change if it is opt-in.
Related Issues / Discussions
https://discord.com/channels/1020123559063990373/1278825261432967169/1347633191816527985
QA Instructions
Try the switcher node out.
Merge Plan
n/a
Checklist
- [x] The PR has a short but descriptive title, suitable for a changelog
- [ ] Tests added / updated (if applicable)
- [ ] Documentation added / updated (if applicable)
- [ ] Updated
What's Newcopy (if doing a release after this PR)