Skip to content

Commit

Permalink
loras
Browse files Browse the repository at this point in the history
  • Loading branch information
zero01101 committed Jul 9, 2023
1 parent 7b1cd4f commit 4b98823
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand Down
32 changes: 31 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ async function testHostConnection() {
controlNetModelAutoComplete,
controlNetModuleAutoComplete
);
// getLoras();
getLoras();
// getTIEmbeddings();
// getHypernets();
firstTimeOnline = false;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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";

Expand Down

0 comments on commit 4b98823

Please sign in to comment.