fix getmodels that seems to have broken with merge
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
dc914d9243
commit
047d5ef01f
1 changed files with 24 additions and 14 deletions
38
js/index.js
38
js/index.js
|
@ -642,23 +642,33 @@ async function getUpscalers() {
|
||||||
|
|
||||||
async function getModels() {
|
async function getModels() {
|
||||||
var url = document.getElementById("host").value + "/sdapi/v1/sd-models";
|
var url = document.getElementById("host").value + "/sdapi/v1/sd-models";
|
||||||
await fetch(url)
|
try {
|
||||||
.then((response) => response.json())
|
const response = await fetch(url);
|
||||||
.then((data) => {
|
const data = await response.json();
|
||||||
modelAutoComplete.options = data.map((option) => ({
|
|
||||||
name: option.title,
|
|
||||||
value: option.title,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// get currently loaded model
|
modelAutoComplete.options = data.map((option) => ({
|
||||||
|
name: option.title,
|
||||||
|
value: option.title,
|
||||||
|
}));
|
||||||
|
|
||||||
await fetch(document.getElementById("host").value + "/sdapi/v1/options")
|
try {
|
||||||
.then((response) => response.json())
|
const optResponse = await fetch(
|
||||||
.then((data) => {
|
document.getElementById("host").value + "/sdapi/v1/options"
|
||||||
var model = data.sd_model_checkpoint;
|
);
|
||||||
|
const optData = await optResponse.json();
|
||||||
|
|
||||||
|
const model = optData.sd_model_checkpoint;
|
||||||
console.log("Current model: " + model);
|
console.log("Current model: " + model);
|
||||||
});
|
modelAutoComplete.value = model;
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("[index] Failed to fetch current model:");
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("[index] Failed to fetch models:");
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
|
// get currently loaded model
|
||||||
|
|
||||||
modelAutoComplete.onchange.on(async ({value}) => {
|
modelAutoComplete.onchange.on(async ({value}) => {
|
||||||
console.log(`[index] Changing model to [${value}]`);
|
console.log(`[index] Changing model to [${value}]`);
|
||||||
|
|
Loading…
Reference in a new issue