mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix getting VAEs for SD forge
This commit is contained in:
@@ -105,22 +105,26 @@ router.post('/upscalers', jsonParser, async (request, response) => {
|
|||||||
|
|
||||||
router.post('/vaes', jsonParser, async (request, response) => {
|
router.post('/vaes', jsonParser, async (request, response) => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(request.body.url);
|
const autoUrl = urlJoin(request.body.url, '/sdapi/v1/sd-vae');
|
||||||
url.pathname = '/sdapi/v1/sd-vae';
|
const forgeUrl = urlJoin(request.body.url, '/sdapi/v1/sd-modules');
|
||||||
|
|
||||||
const result = await fetch(url, {
|
const requestInit = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': getBasicAuthHeader(request.body.auth),
|
'Authorization': getBasicAuthHeader(request.body.auth),
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
const results = await Promise.allSettled([
|
||||||
|
fetch(autoUrl, requestInit).then(r => r.ok ? r.json() : Promise.reject(r.statusText)),
|
||||||
|
fetch(forgeUrl, requestInit).then(r => r.ok ? r.json() : Promise.reject(r.statusText)),
|
||||||
|
]);
|
||||||
|
|
||||||
if (!result.ok) {
|
const data = results.find(r => r.status === 'fulfilled')?.value;
|
||||||
|
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
throw new Error('SD WebUI returned an error.');
|
throw new Error('SD WebUI returned an error.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {any} */
|
|
||||||
const data = await result.json();
|
|
||||||
const names = data.map(x => x.model_name);
|
const names = data.map(x => x.model_name);
|
||||||
return response.send(names);
|
return response.send(names);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Reference in New Issue
Block a user