pamparamm / ComfyUI-ppm

Fixed AttentionCouple/NegPip(negative weights in prompts), more CFG++ samplers, etc.
GNU Affero General Public License v3.0
56 stars 4 forks source link

Fixes AttentionCouplePPM node not working with API workflow #5

Closed Quaggles closed 3 weeks ago

Quaggles commented 3 weeks ago

When using AttentionCouplePPM through a workflow API added regions (cond# and mask#) aren't connected (Try loading this workflow to see the issue: AttentionCouple_PPM_API.json).

This seems to be because extra region inputs are currently only added with the Add Region button in the context menu, since the API workflow spawns the node and tries to connect the inputs it doesn't know about the additional inputs so it fails to connect them. Other custom nodes seem to handle this situation by subscribing to nodeType.prototype.onConnectionsChange then using that to automatically add the extra input slots when the previous ones have been connected.

This pull request adds that functionality, when model and base_mask are connected it will automatically add cond_1 and mask_1 inputs (As if you clicked add region), then if those are linked it will automatically create cond_2 and mask_2, and so on. The existing add and remove region buttons still work and the attached API workflow json will now load.

pamparamm commented 3 weeks ago

Good job! I think I'll merge your PR into another branch and make a few changes like adding a call to original onConnectionsChange and making new inputs optional (making Add Region/Remove Region buttons completely obsolete).

pamparamm commented 3 weeks ago

I've pushed changes to master branch and updated readme. Input management is now completely automatic - no buttons required. @Quaggles, can you please check if everything works for you?

Quaggles commented 3 weeks ago

Yep works for my API usage, thanks