diff --git a/py/autocomplete.py b/py/autocomplete.py index d3a879e..8ac6a05 100644 --- a/py/autocomplete.py +++ b/py/autocomplete.py @@ -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))) \ No newline at end of file + return web.json_response(list(map(lambda a: os.path.splitext(a)[0], loras))) diff --git a/web/js/autocompleter.js b/web/js/autocompleter.js index 5a54dc8..8f473e8 100644 --- a/web/js/autocompleter.js +++ b/web/js/autocompleter.js @@ -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", { diff --git a/web/js/common/autocomplete.js b/web/js/common/autocomplete.js index 862133b..a347509 100644 --- a/web/js/common/autocomplete.js +++ b/web/js/common/autocomplete.js @@ -315,6 +315,7 @@ export class TextAreaAutoComplete { static globalSeparator = ""; static enabled = true; static replacer = undefined; + static lorasEnabled = false; /** @type {Record>} */ static groups = {}; @@ -322,6 +323,8 @@ export class TextAreaAutoComplete { static globalGroups = new Set(); /** @type {Record} */ static globalWords = {}; + /** @type {Record} */ + static globalWordsExclLoras = {}; /** @type {HTMLTextAreaElement} */ el;