feat: add LoraInfo_UTK node - 移植LoRA信息查询节点

This commit is contained in:
Cyber Dick Lang
2025-07-15 17:37:47 +08:00
parent e7b27ef073
commit 914d753fb6
4 changed files with 246 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
import { api } from '../../scripts/api.js';
app.registerExtension({
name: "LoraInfo_UTK",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "LoraInfo_UTK") {
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
onNodeCreated ? onNodeCreated.apply(this, []) : undefined;
this.baseModelWidget = ComfyWidgets["STRING"](this, "Base Model", ["STRING", { multiline: false }], app).widget;
this.showValueWidget = ComfyWidgets["STRING"](
this,
"output",
["STRING", { multiline: true }],
app,
).widget;
const [loraNameWidget, baseModelWidget, outputWidget] = this.widgets;
loraNameWidget.callback = () => {
const value = loraNameWidget.value;
const body = new FormData();
body.append("lora_name", value);
api
.fetchApi("/lora_info_utk", { method: "POST", body })
.then((response) => response.json())
.then((resp) => {
baseModelWidget.value = resp.baseModel;
outputWidget.value = resp.output;
});
};
}
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, [message]);
this.showValueWidget.value = message.text[0];
this.baseModelWidget.value = message.model[0];
}
}
},
});