This commit is contained in:
tim h 2023-07-08 20:20:55 -05:00
parent 7b1cd4f267
commit 4b98823f3b
2 changed files with 33 additions and 1 deletions

View file

@ -147,6 +147,8 @@
value="-1"
step="1" />
<br />
<label>Lora:</label>
<div id="lora-ac-select"></div>
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
<label for="cbxHRFix">Apply Txt2Img HRfix</label>
<br />

View file

@ -426,7 +426,7 @@ async function testHostConnection() {
controlNetModelAutoComplete,
controlNetModuleAutoComplete
);
// getLoras();
getLoras();
// getTIEmbeddings();
// getHypernets();
firstTimeOnline = false;
@ -652,6 +652,18 @@ modelAutoComplete.onchange.on(({value}) => {
).style.backgroundColor = "#fcc";
});
let loraAutoComplete = createAutoComplete(
"LoRa",
document.getElementById("lora-ac-select")
);
loraAutoComplete.onchange.on(({value}) => {
// add selected lora to the end of the prompt
let passVal = " <lora:" + value + ":1>";
let promptInput = document.getElementById("prompt");
promptInput.value += passVal;
let promptThing = prompt;
});
const samplerAutoComplete = createAutoComplete(
"Sampler",
document.getElementById("sampler-ac-select")
@ -1180,6 +1192,24 @@ async function getModels(refresh = false) {
}
}
async function getLoras() {
var url = document.getElementById("host").value + "/sdapi/v1/loras";
let opt = null;
try {
const response = await fetch(url);
const data = await response.json();
loraAutoComplete.options = data.map((lora) => ({
name: lora.name,
value: lora.name,
}));
} catch (e) {
console.warn("[index] Failed to fetch loras");
console.warn(e);
}
}
async function getConfig() {
var url = document.getElementById("host").value + "/sdapi/v1/options";