-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poc of use js front end to get loras list #156
Merged
ccssu
merged 3 commits into
add_shared_lora_loader_node
from
support_get_loras_in_js_end
Sep 28, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,44 @@ | ||
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(); | ||
// console.log("loras_list:", loras_list); | ||
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
guess_config, | ||
guess_url_from_node, | ||
) | ||
from .utils import filter_files_extensions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前端的主要作用,是通过设置 shareid 那个文本框的回调,监控文本改变事件。
然后在文本改变的事件里,像后端发请求,得到 loras list