mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-01-26 19:19:57 +00:00
Fix for hash collisions as long as the mapping file specifies a name in addition
This commit is contained in:
@@ -17,8 +17,16 @@ async function load() {
|
||||
const parts = line.split(",");
|
||||
const hash = parts[0];
|
||||
const keywords = parts[1].replaceAll("| ", ", ").replaceAll("|", ", ").trim();
|
||||
const name = parts[2]?.trim() || "none"
|
||||
|
||||
modelKeywordDict.set(hash, keywords);
|
||||
if (modelKeywordDict.has(hash) && name !== "none") {
|
||||
// Add a new name key if the hash already exists
|
||||
modelKeywordDict.get(hash).set(name, keywords);
|
||||
} else {
|
||||
// Create new hash entry
|
||||
let map = new Map().set(name, keywords);
|
||||
modelKeywordDict.set(hash, map);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Error loading model-keywords list: " + e);
|
||||
|
||||
@@ -447,7 +447,21 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout
|
||||
let keywordsLength = 0;
|
||||
if (TAC_CFG.modelKeywordCompletion && modelKeywordPath.length > 0 && (tagType === ResultType.lora || tagType === ResultType.lyco)) {
|
||||
if (result.hash && result.hash !== "NOFILE" && result.hash.length > 0) {
|
||||
let keywords = modelKeywordDict.get(result.hash);
|
||||
let keywords = null;
|
||||
let nameDict = modelKeywordDict.get(result.hash);
|
||||
let name = result.text + ".safetensors";
|
||||
|
||||
console.log(name, nameDict);
|
||||
|
||||
if (nameDict) {
|
||||
if (nameDict.size > 1)
|
||||
keywords = nameDict.get(name);
|
||||
else
|
||||
keywords = nameDict.get("none");
|
||||
}
|
||||
|
||||
console.log(keywords);
|
||||
|
||||
if (keywords && keywords.length > 0) {
|
||||
newPrompt = `${keywords}, ${newPrompt}`;
|
||||
keywordsLength = keywords.length + 2; // +2 for the comma and space
|
||||
|
||||
Reference in New Issue
Block a user