| 151 | ) { |
| 152 | addMenuHandler(nodeType, function (_, options) { |
| 153 | function addLora(type) { |
| 154 | const loraNode = addNode(type, this); |
| 155 | |
| 156 | const modelLinks = this.outputs[0].links ? this.outputs[0].links.map((l) => ({ ...graph.links[l] })) : []; |
| 157 | const clipLinks = this.outputs[1].links ? this.outputs[1].links.map((l) => ({ ...graph.links[l] })) : []; |
| 158 | |
| 159 | this.disconnectOutput(0); |
| 160 | this.disconnectOutput(1); |
| 161 | |
| 162 | this.connect(0, loraNode, 0); |
| 163 | this.connect(1, loraNode, 1); |
| 164 | |
| 165 | for (const modelLink of modelLinks) { |
| 166 | loraNode.connect(0, modelLink.target_id, modelLink.target_slot); |
| 167 | } |
| 168 | |
| 169 | for (const clipLink of clipLinks) { |
| 170 | loraNode.connect(1, clipLink.target_id, clipLink.target_slot); |
| 171 | } |
| 172 | } |
| 173 | options.unshift( |
| 174 | { |
| 175 | content: "Add LoRA", |