diff --git a/public/index.html b/public/index.html index f59c28e7e..5e3de4587 100644 --- a/public/index.html +++ b/public/index.html @@ -2427,6 +2427,7 @@ + @@ -2938,6 +2939,20 @@ +
+

Block Entropy API Key

+
+ + +
+
+ For privacy reasons, your API key will be hidden after you reload the page. +
+

Select a Model

+
+ +
+

Custom Endpoint (Base URL)

diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 2cfeb1f6b..243965290 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -378,6 +378,7 @@ function RA_autoconnect(PrevApi) { || (secret_state[SECRET_KEYS.PERPLEXITY] && oai_settings.chat_completion_source == chat_completion_sources.PERPLEXITY) || (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ) || (secret_state[SECRET_KEYS.ZEROONEAI] && oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) + || (secret_state[SECRET_KEYS.BLOCKENTROPY] && oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) ) { $('#api_button_openai').trigger('click'); diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index 008ef0f15..af3516fba 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -50,6 +50,7 @@ const sources = { drawthings: 'drawthings', pollinations: 'pollinations', stability: 'stability', + blockentropy: 'blockentropy', }; const initiators = { @@ -1221,7 +1222,7 @@ async function onModelChange() { extension_settings.sd.model = $('#sd_model').find(':selected').val(); saveSettingsDebounced(); - const cloudSources = [sources.horde, sources.novel, sources.openai, sources.togetherai, sources.pollinations, sources.stability]; + const cloudSources = [sources.horde, sources.novel, sources.openai, sources.togetherai, sources.pollinations, sources.stability, sources.blockentropy]; if (cloudSources.includes(extension_settings.sd.source)) { return; @@ -1433,6 +1434,9 @@ async function loadSamplers() { case sources.stability: samplers = ['N/A']; break; + case sources.blockentropy: + samplers = ['N/A']; + break; } for (const sampler of samplers) { @@ -1619,6 +1623,9 @@ async function loadModels() { case sources.stability: models = await loadStabilityModels(); break; + case sources.blockentropy: + models = await loadBlockEntropyModels(); + break; } for (const model of models) { @@ -1713,6 +1720,26 @@ async function loadTogetherAIModels() { return []; } +async function loadBlockEntropyModels() { + if (!secret_state[SECRET_KEYS.BLOCKENTROPY]) { + console.debug('Block Entropy API key is not set.'); + return []; + } + + const result = await fetch('/api/sd/blockentropy/models', { + method: 'POST', + headers: getRequestHeaders(), + }); + console.log(result); + if (result.ok) { + const data = await result.json(); + console.log(data); + return data; + } + + return []; +} + async function loadHordeModels() { const result = await fetch('/api/horde/sd-models', { method: 'POST', @@ -1979,6 +2006,9 @@ async function loadSchedulers() { case sources.stability: schedulers = ['N/A']; break; + case sources.blockentropy: + schedulers = ['N/A']; + break; } for (const scheduler of schedulers) { @@ -2055,6 +2085,9 @@ async function loadVaes() { case sources.stability: vaes = ['N/A']; break; + case sources.blockentropy: + vaes = ['N/A']; + break; } for (const vae of vaes) { @@ -2583,6 +2616,9 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP case sources.stability: result = await generateStabilityImage(prefixedPrompt, negativePrompt, signal); break; + case sources.blockentropy: + result = await generateBlockEntropyImage(prefixedPrompt, negativePrompt, signal); + break; } if (!result.data) { @@ -2638,6 +2674,31 @@ async function generateTogetherAIImage(prompt, negativePrompt, signal) { } } +async function generateBlockEntropyImage(prompt, negativePrompt, signal) { + const result = await fetch('/api/sd/blockentropy/generate', { + method: 'POST', + headers: getRequestHeaders(), + signal: signal, + body: JSON.stringify({ + prompt: prompt, + negative_prompt: negativePrompt, + model: extension_settings.sd.model, + steps: extension_settings.sd.steps, + width: extension_settings.sd.width, + height: extension_settings.sd.height, + seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined, + }), + }); + + if (result.ok) { + const data = await result.json(); + return { format: 'png', data: data.images[0] }; + } else { + const text = await result.text(); + throw new Error(text); + } +} + /** * Generates an image using the Pollinations API. * @param {string} prompt - The main instruction used to guide the image generation. @@ -3451,6 +3512,8 @@ function isValidState() { return true; case sources.stability: return secret_state[SECRET_KEYS.STABILITY]; + case sources.blockentropy: + return secret_state[SECRET_KEYS.BLOCKENTROPY]; } } diff --git a/public/scripts/extensions/stable-diffusion/settings.html b/public/scripts/extensions/stable-diffusion/settings.html index 33317f695..e29bb4bb2 100644 --- a/public/scripts/extensions/stable-diffusion/settings.html +++ b/public/scripts/extensions/stable-diffusion/settings.html @@ -48,6 +48,7 @@ +
@@ -378,7 +379,7 @@
-
+