-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SharedLoraLoader node * poc of use js front end to get loras list (#156) * poc * refine * refine --------- Co-authored-by: FengWen <[email protected]> * fix SharedLoraLoader * Remove unused comments --------- Co-authored-by: Yao Chi <[email protected]>
- Loading branch information
1 parent
64cad67
commit a113f3e
Showing
6 changed files
with
232 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { api } from "../../../scripts/api.js"; | ||
import { app } from "../../scripts/app.js"; | ||
app.registerExtension({ | ||
name: "bizyair.siliconcloud.share.lora.loader", | ||
async beforeRegisterNodeDef(nodeType, nodeData, app) { | ||
if (nodeData.name === "BizyAir_SharedLoraLoader") { | ||
async function onTextChange(share_id, canvas, comfynode) { | ||
console.log("share_id:", share_id); | ||
const response = await api.fetchApi(`/bizyair/modelhost/${share_id}/models/files?type=bizyair/lora`, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
|
||
const { data: loras_list } = await response.json(); | ||
const lora_name_widget = comfynode.widgets.find(widget => widget.name === "lora_name"); | ||
if (loras_list.length > 0) { | ||
lora_name_widget.value = loras_list[0]; | ||
lora_name_widget.options.values = loras_list; | ||
} else { | ||
console.log("No loras found in the response"); | ||
lora_name_widget.value = ""; | ||
lora_name_widget.options.values = []; | ||
} | ||
} | ||
|
||
function setWigetCallback(){ | ||
const shareid_widget = this.widgets.find(widget => widget.name === "share_id"); | ||
if (shareid_widget) { | ||
shareid_widget.callback = onTextChange; | ||
} else { | ||
console.log("share_id widget not found"); | ||
} | ||
} | ||
const onNodeCreated = nodeType.prototype.onNodeCreated | ||
nodeType.prototype.onNodeCreated = function () { | ||
onNodeCreated?.apply(this, arguments); | ||
setWigetCallback.call(this, arguments); | ||
}; | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from .path_manager import ( | ||
convert_prompt_label_path_to_real_path, | ||
disable_refresh_options, | ||
enable_refresh_options, | ||
get_filename_list, | ||
guess_config, | ||
guess_url_from_node, | ||
) | ||
from .utils import filter_files_extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters