From aed449c882086d01f240e4a97e1bcb001fb6ab6c Mon Sep 17 00:00:00 2001 From: Gin Date: Thu, 11 May 2023 11:21:53 +0800 Subject: [PATCH] fix chant issue --- javascript/_result.js | 3 ++- javascript/ext_chants.js | 13 ++++++------- javascript/ext_embeddings.js | 2 +- javascript/ext_hypernets.js | 2 +- javascript/ext_loras.js | 2 +- javascript/ext_lycos.js | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/javascript/_result.js b/javascript/_result.js index 7fa5b09..0bf02d1 100644 --- a/javascript/_result.js +++ b/javascript/_result.js @@ -10,7 +10,8 @@ const ResultType = Object.freeze({ "yamlWildcard": 6, "hypernetwork": 7, "lora": 8, - "lyco": 9 + "lyco": 9, + "chant": 10 }); // Class to hold result data and annotations to make it clearer to use diff --git a/javascript/ext_chants.js b/javascript/ext_chants.js index d864db3..0955327 100644 --- a/javascript/ext_chants.js +++ b/javascript/ext_chants.js @@ -1,12 +1,12 @@ -const CHANT_REGEX = /%(?!c:)[^,> ]*>?/gg; +const CHANT_REGEX = /<(?!e:|h:|l:)[^,> ]*>?/g; const CHANT_TRIGGER = () => TAC_CFG.useChants && tagword.match(CHANT_REGEX); class ChantParser extends BaseTagParser { parse() { // Show Chant let tempResults = []; - if (tagword !== "%" && tagword !== "%c:") { - let searchTerm = tagword.replace("%c:", "").replace("%", ""); + if (tagword !== "<" && tagword !== " x.term.toLowerCase().includes(searchTerm); tempResults = loras.filter(x => filterCondition(x)); // Filter by tagword } else { @@ -16,8 +16,8 @@ class ChantParser extends BaseTagParser { // Add final results let finalResults = []; tempResults.forEach(t => { - let result = new AutocompleteResult(t.content.trim(), ResultType.json) - result.meta = t.name; + let result = new AutocompleteResult(t.content.trim(), ResultType.chant) + result.meta = t.name + " Chant"; finalResults.push(result); }); @@ -37,8 +37,7 @@ async function load() { function sanitize(tagType, text) { if (tagType === ResultType.chant) { - let selected = chants.find(x => x.content === text); - return `%c:${selected.term}:${TAC_CFG.extraNetworksDefaultMultiplier}>`; + return text.replace(/^.*?: /g, ""); } return null; } diff --git a/javascript/ext_embeddings.js b/javascript/ext_embeddings.js index 444b81d..30ce48f 100644 --- a/javascript/ext_embeddings.js +++ b/javascript/ext_embeddings.js @@ -1,4 +1,4 @@ -const EMB_REGEX = /<(?!l:|h:)[^,> ]*>?/g; +const EMB_REGEX = /<(?!l:|h:|c:)[^,> ]*>?/g; const EMB_TRIGGER = () => TAC_CFG.useEmbeddings && tagword.match(EMB_REGEX); class EmbeddingParser extends BaseTagParser { diff --git a/javascript/ext_hypernets.js b/javascript/ext_hypernets.js index ff64c03..7f564fd 100644 --- a/javascript/ext_hypernets.js +++ b/javascript/ext_hypernets.js @@ -1,4 +1,4 @@ -const HYP_REGEX = /<(?!e:|l:)[^,> ]*>?/g; +const HYP_REGEX = /<(?!e:|l:|c:)[^,> ]*>?/g; const HYP_TRIGGER = () => TAC_CFG.useHypernetworks && tagword.match(HYP_REGEX); class HypernetParser extends BaseTagParser { diff --git a/javascript/ext_loras.js b/javascript/ext_loras.js index 253a768..dff4a1b 100644 --- a/javascript/ext_loras.js +++ b/javascript/ext_loras.js @@ -1,4 +1,4 @@ -const LORA_REGEX = /<(?!e:|h:)[^,> ]*>?/g; +const LORA_REGEX = /<(?!e:|h:|c:)[^,> ]*>?/g; const LORA_TRIGGER = () => TAC_CFG.useLoras && tagword.match(LORA_REGEX); class LoraParser extends BaseTagParser { diff --git a/javascript/ext_lycos.js b/javascript/ext_lycos.js index 80da266..86f7552 100644 --- a/javascript/ext_lycos.js +++ b/javascript/ext_lycos.js @@ -1,4 +1,4 @@ -const LYCO_REGEX = /<(?!e:|h:)[^,> ]*>?/g; +const LYCO_REGEX = /<(?!e:|h:|c:)[^,> ]*>?/g; const LYCO_TRIGGER = () => TAC_CFG.useLycos && tagword.match(LYCO_REGEX); class LycoParser extends BaseTagParser {