make lora autocompletion opt-in
This commit is contained in:
+1
-1
@@ -26,4 +26,4 @@ async def update_autocomplete(request):
|
||||
@PromptServer.instance.routes.get("/pysssss/loras")
|
||||
async def get_loras(request):
|
||||
loras = folder_paths.get_filename_list("loras")
|
||||
return web.json_response(list(map(lambda a: os.path.splitext(a)[0], loras)))
|
||||
return web.json_response(list(map(lambda a: os.path.splitext(a)[0], loras)))
|
||||
|
||||
+41
-1
@@ -127,6 +127,13 @@ async function addCustomWords(text) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleLoras() {
|
||||
[TextAreaAutoComplete.globalWords, TextAreaAutoComplete.globalWordsExclLoras] = [
|
||||
TextAreaAutoComplete.globalWordsExclLoras,
|
||||
TextAreaAutoComplete.globalWords,
|
||||
];
|
||||
}
|
||||
|
||||
class EmbeddingInfoDialog extends ModelInfoDialog {
|
||||
async addInfo() {
|
||||
super.addInfo();
|
||||
@@ -287,7 +294,20 @@ app.registerExtension({
|
||||
TextAreaAutoComplete.updateWords("pysssss.loras", words);
|
||||
}
|
||||
|
||||
Promise.all([addEmbeddings(), addLoras(), addCustomWords()]);
|
||||
// store global words with/without loras
|
||||
Promise.all([addEmbeddings(), addCustomWords()])
|
||||
.then(() => {
|
||||
TextAreaAutoComplete.globalWordsExclLoras = Object.assign(
|
||||
{},
|
||||
TextAreaAutoComplete.globalWords
|
||||
);
|
||||
})
|
||||
.then(addLoras)
|
||||
.then(() => {
|
||||
if (!TextAreaAutoComplete.lorasEnabled) {
|
||||
toggleLoras(); // off by default
|
||||
}
|
||||
});
|
||||
|
||||
const STRING = ComfyWidgets.STRING;
|
||||
const SKIP_WIDGETS = new Set(["ttN xyPlot.x_values", "ttN xyPlot.y_values"]);
|
||||
@@ -365,6 +385,26 @@ app.registerExtension({
|
||||
}),
|
||||
]
|
||||
),
|
||||
$el(
|
||||
"label",
|
||||
{
|
||||
textContent: "Loras enabled ",
|
||||
style: {
|
||||
display: "block",
|
||||
},
|
||||
},
|
||||
[
|
||||
$el("input", {
|
||||
type: "checkbox",
|
||||
checked: !!TextAreaAutoComplete.lorasEnabled,
|
||||
onchange: (event) => {
|
||||
const checked = !!event.target.checked;
|
||||
TextAreaAutoComplete.lorasEnabled = checked;
|
||||
toggleLoras();
|
||||
},
|
||||
}),
|
||||
]
|
||||
),
|
||||
$el(
|
||||
"label",
|
||||
{
|
||||
|
||||
@@ -315,6 +315,7 @@ export class TextAreaAutoComplete {
|
||||
static globalSeparator = "";
|
||||
static enabled = true;
|
||||
static replacer = undefined;
|
||||
static lorasEnabled = false;
|
||||
|
||||
/** @type {Record<string, Record<string, AutoCompleteEntry>>} */
|
||||
static groups = {};
|
||||
@@ -322,6 +323,8 @@ export class TextAreaAutoComplete {
|
||||
static globalGroups = new Set();
|
||||
/** @type {Record<string, AutoCompleteEntry>} */
|
||||
static globalWords = {};
|
||||
/** @type {Record<string, AutoCompleteEntry>} */
|
||||
static globalWordsExclLoras = {};
|
||||
|
||||
/** @type {HTMLTextAreaElement} */
|
||||
el;
|
||||
|
||||
Reference in New Issue
Block a user