Add option to load only user list for keywords

This commit is contained in:
DominikDoom
2023-07-22 14:08:32 +02:00
parent f1d911834b
commit c41372143d
3 changed files with 9 additions and 4 deletions

View File

@@ -5,11 +5,16 @@ async function load() {
if (modelKeywordPath.length > 0 && modelKeywordDict.size === 0) {
try {
let lines = (await readFile(`${modelKeywordPath}/lora-keyword.txt`)).split("\n");
let lines = [];
// Only add default keywords if wanted by the user
if (TAC_CFG.modelKeywordCompletion !== "Only user list")
lines = (await readFile(`${modelKeywordPath}/lora-keyword.txt`)).split("\n");
// Add custom user keywords if the file exists
if (customFileExists)
lines = lines.concat((await readFile(`${modelKeywordPath}/lora-keyword-user.txt`)).split("\n"));
if (lines.length === 0) return;
lines = lines.filter(x => x.trim().length > 0 && x.trim()[0] !== "#") // Remove empty lines and comments
// Add to the dict

View File

@@ -445,7 +445,7 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout
// Add lora/lyco keywords if enabled and found
let keywordsLength = 0;
if (TAC_CFG.modelKeywordCompletion && modelKeywordPath.length > 0 && (tagType === ResultType.lora || tagType === ResultType.lyco)) {
if (TAC_CFG.modelKeywordCompletion !== "Never" && modelKeywordPath.length > 0 && (tagType === ResultType.lora || tagType === ResultType.lyco)) {
if (result.hash && result.hash !== "NOFILE" && result.hash.length > 0) {
let keywords = null;
let nameDict = modelKeywordDict.get(result.hash);
@@ -805,7 +805,7 @@ function rubyTagClicked(node, textBefore, prompt, textArea) {
// Check if the last edit was the keyword insertion, and catch undo/redo in that case
function checkKeywordInsertionUndo(textArea, event) {
if (!TAC_CFG.modelKeywordCompletion) return;
if (TAC_CFG.modelKeywordCompletion === "Never") return;
switch (event.inputType) {
case "historyUndo":