fix chant issue

This commit is contained in:
Gin
2023-05-11 11:21:53 +08:00
parent a724da362c
commit aed449c882
6 changed files with 12 additions and 12 deletions

View File

@@ -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

View File

@@ -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 !== "<c:") {
let searchTerm = tagword.replace("<c:", "").replace("<", "");
let filterCondition = x => 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;
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {