make lora autocompletion opt-in

This commit is contained in:
qrtal
2024-01-15 13:02:23 -05:00
parent 77b0de59af
commit b40b6bc153
3 changed files with 45 additions and 2 deletions
+1 -1
View File
@@ -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
View File
@@ -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",
{
+3
View File
@@ -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;