From af1675813f099e94f8dfb3d3c95f5d1fa8eb243b Mon Sep 17 00:00:00 2001 From: Justin Firth Date: Sat, 24 Feb 2024 11:34:11 -0500 Subject: [PATCH] Restore image steps setting when Settings modal is presented --- src/lib/apis/images/index.ts | 32 +++++++++++++++++++ .../components/chat/Settings/Images.svelte | 2 ++ 2 files changed, 34 insertions(+) diff --git a/src/lib/apis/images/index.ts b/src/lib/apis/images/index.ts index c64bf2ba..f05ce0b7 100644 --- a/src/lib/apis/images/index.ts +++ b/src/lib/apis/images/index.ts @@ -198,6 +198,38 @@ export const updateImageSize = async (token: string = '', size: string) => { return res.IMAGE_SIZE; }; +export const getImageSteps = async (token: string = '') => { + let error = null; + + const res = await fetch(`${IMAGES_API_BASE_URL}/steps`, { + method: 'GET', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + ...(token && { authorization: `Bearer ${token}` }) + } + }) + .then(async (res) => { + if (!res.ok) throw await res.json(); + return res.json(); + }) + .catch((err) => { + console.log(err); + if ('detail' in err) { + error = err.detail; + } else { + error = 'Server connection failed'; + } + return null; + }); + + if (error) { + throw error; + } + + return res.IMAGE_STEPS; +}; + export const updateImageSteps = async (token: string = '', steps: number) => { let error = null; diff --git a/src/lib/components/chat/Settings/Images.svelte b/src/lib/components/chat/Settings/Images.svelte index 2f6daa10..6e349861 100644 --- a/src/lib/components/chat/Settings/Images.svelte +++ b/src/lib/components/chat/Settings/Images.svelte @@ -13,6 +13,7 @@ updateAUTOMATIC1111Url, updateDefaultDiffusionModel, updateImageSize, + getImageSteps, updateImageSteps } from '$lib/apis/images'; import { getBackendConfig } from '$lib/apis'; @@ -85,6 +86,7 @@ if (enableImageGeneration && AUTOMATIC1111_BASE_URL) { imageSize = await getImageSize(localStorage.token); + steps = await getImageSteps(localStorage.token); getModels(); } }