Auto-refresh embedding list after model change

Uses own API endpoint and doesn't force-reload to skip unneeded work
(only works for A1111 as SD.Next model change detection isn't implemented yet)
This commit is contained in:
DominikDoom
2023-12-12 14:13:13 +01:00
parent 886704e351
commit f840586b6b
2 changed files with 20 additions and 6 deletions

View File

@@ -1269,6 +1269,13 @@ async function refreshTacTempFiles(api = false) {
}
}
async function refreshEmbeddings() {
await postAPI("tacapi/v1/refresh-embeddings", null);
embeddings = [];
await processQueue(QUEUE_FILE_LOAD, null);
console.log("TAC: Refreshed embeddings");
}
function addAutocompleteToArea(area) {
// Return if autocomplete is disabled for the current area type in config
let textAreaId = getTextAreaIdentifier(area);
@@ -1373,6 +1380,7 @@ async function setup() {
if (mutation.type === "attributes" && mutation.attributeName === "title") {
currentModelHash = mutation.target.title;
updateModelName();
refreshEmbeddings();
}
}
});