mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #2640 from edk208/release
Adding Block Entropy API endpoints for chat, image, and video generation
This commit is contained in:
3
public/img/blockentropy.svg
Normal file
3
public/img/blockentropy.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 236.38 282.41">
|
||||||
|
<path d="M126.55,0v54.44l-79.87,33.76v93.95l27.53-12.94,43.08,31.09.04-.05v.09l55.21-31.44.13-.08v-80.06l-55.34,24.92v80.2l-42.55-30.7h-.02s0-81.16,0-81.16l57.02-24.11V9.23l93.54,56.12v22.51l-24.34,11.53,1.84,90.56-88.45,51.47-.13.08v34.46L5.23,198.97v-65.56H0v66.92c0,.85.41,1.64,1.11,2.14l113.13,79.91v.05l.04-.02h0s0,0,0,0l121.97-73.54.13-.08v-126.13l-5.84,2.76v-22.94h-.3l.11-.18L126.55,0Z" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 509 B |
@ -2427,6 +2427,7 @@
|
|||||||
<optgroup>
|
<optgroup>
|
||||||
<option value="01ai">01.AI (Yi)</option>
|
<option value="01ai">01.AI (Yi)</option>
|
||||||
<option value="ai21">AI21</option>
|
<option value="ai21">AI21</option>
|
||||||
|
<option value="blockentropy">Block Entropy</option>
|
||||||
<option value="claude">Claude</option>
|
<option value="claude">Claude</option>
|
||||||
<option value="cohere">Cohere</option>
|
<option value="cohere">Cohere</option>
|
||||||
<option value="groq">Groq</option>
|
<option value="groq">Groq</option>
|
||||||
@ -2952,6 +2953,20 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<form id="blockentropy_form" data-source="blockentropy">
|
||||||
|
<h4 data-i18n="Block Entropy API Key">Block Entropy API Key</h4>
|
||||||
|
<div class="flex-container">
|
||||||
|
<input id="api_key_blockentropy" name="api_key_blockentropy" class="text_pole flex1" maxlength="500" value="" type="text" autocomplete="off">
|
||||||
|
<div title="Clear your API key" data-i18n="[title]Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_blockentropy"></div>
|
||||||
|
</div>
|
||||||
|
<div data-for="api_key_blockentropy" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you reload the page.">
|
||||||
|
For privacy reasons, your API key will be hidden after you reload the page.
|
||||||
|
</div>
|
||||||
|
<h4 data-i18n="Select a Model">Select a Model</h4>
|
||||||
|
<div class="flex-container">
|
||||||
|
<select id="model_blockentropy_select" class="text_pole"></select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<form id="custom_form" data-source="custom">
|
<form id="custom_form" data-source="custom">
|
||||||
<h4 data-i18n="Custom Endpoint (Base URL)">Custom Endpoint (Base URL)</h4>
|
<h4 data-i18n="Custom Endpoint (Base URL)">Custom Endpoint (Base URL)</h4>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
|
@ -380,6 +380,7 @@ function RA_autoconnect(PrevApi) {
|
|||||||
|| (secret_state[SECRET_KEYS.PERPLEXITY] && oai_settings.chat_completion_source == chat_completion_sources.PERPLEXITY)
|
|| (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.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.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)
|
|| (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM)
|
||||||
) {
|
) {
|
||||||
$('#api_button_openai').trigger('click');
|
$('#api_button_openai').trigger('click');
|
||||||
|
@ -51,6 +51,7 @@ const sources = {
|
|||||||
drawthings: 'drawthings',
|
drawthings: 'drawthings',
|
||||||
pollinations: 'pollinations',
|
pollinations: 'pollinations',
|
||||||
stability: 'stability',
|
stability: 'stability',
|
||||||
|
blockentropy: 'blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
const initiators = {
|
const initiators = {
|
||||||
@ -1222,7 +1223,7 @@ async function onModelChange() {
|
|||||||
extension_settings.sd.model = $('#sd_model').find(':selected').val();
|
extension_settings.sd.model = $('#sd_model').find(':selected').val();
|
||||||
saveSettingsDebounced();
|
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)) {
|
if (cloudSources.includes(extension_settings.sd.source)) {
|
||||||
return;
|
return;
|
||||||
@ -1434,6 +1435,9 @@ async function loadSamplers() {
|
|||||||
case sources.stability:
|
case sources.stability:
|
||||||
samplers = ['N/A'];
|
samplers = ['N/A'];
|
||||||
break;
|
break;
|
||||||
|
case sources.blockentropy:
|
||||||
|
samplers = ['N/A'];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const sampler of samplers) {
|
for (const sampler of samplers) {
|
||||||
@ -1620,6 +1624,9 @@ async function loadModels() {
|
|||||||
case sources.stability:
|
case sources.stability:
|
||||||
models = await loadStabilityModels();
|
models = await loadStabilityModels();
|
||||||
break;
|
break;
|
||||||
|
case sources.blockentropy:
|
||||||
|
models = await loadBlockEntropyModels();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const model of models) {
|
for (const model of models) {
|
||||||
@ -1714,6 +1721,26 @@ async function loadTogetherAIModels() {
|
|||||||
return [];
|
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() {
|
async function loadHordeModels() {
|
||||||
const result = await fetch('/api/horde/sd-models', {
|
const result = await fetch('/api/horde/sd-models', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -1980,6 +2007,9 @@ async function loadSchedulers() {
|
|||||||
case sources.stability:
|
case sources.stability:
|
||||||
schedulers = ['N/A'];
|
schedulers = ['N/A'];
|
||||||
break;
|
break;
|
||||||
|
case sources.blockentropy:
|
||||||
|
schedulers = ['N/A'];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const scheduler of schedulers) {
|
for (const scheduler of schedulers) {
|
||||||
@ -2056,6 +2086,9 @@ async function loadVaes() {
|
|||||||
case sources.stability:
|
case sources.stability:
|
||||||
vaes = ['N/A'];
|
vaes = ['N/A'];
|
||||||
break;
|
break;
|
||||||
|
case sources.blockentropy:
|
||||||
|
vaes = ['N/A'];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const vae of vaes) {
|
for (const vae of vaes) {
|
||||||
@ -2584,6 +2617,9 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
|
|||||||
case sources.stability:
|
case sources.stability:
|
||||||
result = await generateStabilityImage(prefixedPrompt, negativePrompt, signal);
|
result = await generateStabilityImage(prefixedPrompt, negativePrompt, signal);
|
||||||
break;
|
break;
|
||||||
|
case sources.blockentropy:
|
||||||
|
result = await generateBlockEntropyImage(prefixedPrompt, negativePrompt, signal);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.data) {
|
if (!result.data) {
|
||||||
@ -2639,6 +2675,40 @@ 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();
|
||||||
|
|
||||||
|
// Default format is 'jpg'
|
||||||
|
let format = 'jpg';
|
||||||
|
|
||||||
|
// Check if a format is specified in the result
|
||||||
|
if (data.format) {
|
||||||
|
format = data.format.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { format: format, data: data.images[0] };
|
||||||
|
} else {
|
||||||
|
const text = await result.text();
|
||||||
|
throw new Error(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an image using the Pollinations API.
|
* Generates an image using the Pollinations API.
|
||||||
* @param {string} prompt - The main instruction used to guide the image generation.
|
* @param {string} prompt - The main instruction used to guide the image generation.
|
||||||
@ -3459,6 +3529,8 @@ function isValidState() {
|
|||||||
return true;
|
return true;
|
||||||
case sources.stability:
|
case sources.stability:
|
||||||
return secret_state[SECRET_KEYS.STABILITY];
|
return secret_state[SECRET_KEYS.STABILITY];
|
||||||
|
case sources.blockentropy:
|
||||||
|
return secret_state[SECRET_KEYS.BLOCKENTROPY];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<label for="sd_source" data-i18n="Source">Source</label>
|
<label for="sd_source" data-i18n="Source">Source</label>
|
||||||
<select id="sd_source">
|
<select id="sd_source">
|
||||||
|
<option value="blockentropy">Block Entropy</option>
|
||||||
<option value="comfy">ComfyUI</option>
|
<option value="comfy">ComfyUI</option>
|
||||||
<option value="drawthings">DrawThings HTTP API</option>
|
<option value="drawthings">DrawThings HTTP API</option>
|
||||||
<option value="extras">Extras API (local / remote)</option>
|
<option value="extras">Extras API (local / remote)</option>
|
||||||
@ -378,7 +379,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-sd-source="novel,togetherai,pollinations,comfy,drawthings,vlad,auto,horde,extras,stability" class="marginTop5">
|
<div data-sd-source="novel,togetherai,pollinations,comfy,drawthings,vlad,auto,horde,extras,stability,blockentropy" class="marginTop5">
|
||||||
<label for="sd_seed">
|
<label for="sd_seed">
|
||||||
<span data-i18n="Seed">Seed</span>
|
<span data-i18n="Seed">Seed</span>
|
||||||
<small data-i18n="(-1 for random)">(-1 for random)</small>
|
<small data-i18n="(-1 for random)">(-1 for random)</small>
|
||||||
|
@ -120,6 +120,7 @@ const default_bias_presets = {
|
|||||||
const max_2k = 2047;
|
const max_2k = 2047;
|
||||||
const max_4k = 4095;
|
const max_4k = 4095;
|
||||||
const max_8k = 8191;
|
const max_8k = 8191;
|
||||||
|
const max_12k = 12287;
|
||||||
const max_16k = 16383;
|
const max_16k = 16383;
|
||||||
const max_32k = 32767;
|
const max_32k = 32767;
|
||||||
const max_64k = 65535;
|
const max_64k = 65535;
|
||||||
@ -186,6 +187,7 @@ export const chat_completion_sources = {
|
|||||||
PERPLEXITY: 'perplexity',
|
PERPLEXITY: 'perplexity',
|
||||||
GROQ: 'groq',
|
GROQ: 'groq',
|
||||||
ZEROONEAI: '01ai',
|
ZEROONEAI: '01ai',
|
||||||
|
BLOCKENTROPY: 'blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
const character_names_behavior = {
|
const character_names_behavior = {
|
||||||
@ -268,6 +270,7 @@ const default_settings = {
|
|||||||
perplexity_model: 'llama-3.1-70b-instruct',
|
perplexity_model: 'llama-3.1-70b-instruct',
|
||||||
groq_model: 'llama-3.1-70b-versatile',
|
groq_model: 'llama-3.1-70b-versatile',
|
||||||
zerooneai_model: 'yi-large',
|
zerooneai_model: 'yi-large',
|
||||||
|
blockentropy_model: 'be-70b-base-llama3.1',
|
||||||
custom_model: '',
|
custom_model: '',
|
||||||
custom_url: '',
|
custom_url: '',
|
||||||
custom_include_body: '',
|
custom_include_body: '',
|
||||||
@ -348,6 +351,7 @@ const oai_settings = {
|
|||||||
perplexity_model: 'llama-3.1-70b-instruct',
|
perplexity_model: 'llama-3.1-70b-instruct',
|
||||||
groq_model: 'llama-3.1-70b-versatile',
|
groq_model: 'llama-3.1-70b-versatile',
|
||||||
zerooneai_model: 'yi-large',
|
zerooneai_model: 'yi-large',
|
||||||
|
blockentropy_model: 'be-70b-base-llama3.1',
|
||||||
custom_model: '',
|
custom_model: '',
|
||||||
custom_url: '',
|
custom_url: '',
|
||||||
custom_include_body: '',
|
custom_include_body: '',
|
||||||
@ -1542,6 +1546,8 @@ function getChatCompletionModel() {
|
|||||||
return oai_settings.groq_model;
|
return oai_settings.groq_model;
|
||||||
case chat_completion_sources.ZEROONEAI:
|
case chat_completion_sources.ZEROONEAI:
|
||||||
return oai_settings.zerooneai_model;
|
return oai_settings.zerooneai_model;
|
||||||
|
case chat_completion_sources.BLOCKENTROPY:
|
||||||
|
return oai_settings.blockentropy_model;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`);
|
throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`);
|
||||||
}
|
}
|
||||||
@ -1655,6 +1661,23 @@ function saveModelList(data) {
|
|||||||
|
|
||||||
$('#model_01ai_select').val(oai_settings.zerooneai_model).trigger('change');
|
$('#model_01ai_select').val(oai_settings.zerooneai_model).trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) {
|
||||||
|
$('#model_blockentropy_select').empty();
|
||||||
|
model_list.forEach((model) => {
|
||||||
|
$('#model_blockentropy_select').append(
|
||||||
|
$('<option>', {
|
||||||
|
value: model.id,
|
||||||
|
text: model.id,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!oai_settings.blockentropy_model && model_list.length > 0) {
|
||||||
|
oai_settings.blockentropy_model = model_list[0].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
|
function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
|
||||||
@ -3015,6 +3038,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
oai_settings.cohere_model = settings.cohere_model ?? default_settings.cohere_model;
|
oai_settings.cohere_model = settings.cohere_model ?? default_settings.cohere_model;
|
||||||
oai_settings.perplexity_model = settings.perplexity_model ?? default_settings.perplexity_model;
|
oai_settings.perplexity_model = settings.perplexity_model ?? default_settings.perplexity_model;
|
||||||
oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model;
|
oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model;
|
||||||
|
oai_settings.blockentropy_model = settings.blockentropy_model ?? default_settings.blockentropy_model;
|
||||||
oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model;
|
oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model;
|
||||||
oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model;
|
oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model;
|
||||||
oai_settings.custom_url = settings.custom_url ?? default_settings.custom_url;
|
oai_settings.custom_url = settings.custom_url ?? default_settings.custom_url;
|
||||||
@ -3094,6 +3118,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
$('#model_groq_select').val(oai_settings.groq_model);
|
$('#model_groq_select').val(oai_settings.groq_model);
|
||||||
$(`#model_groq_select option[value="${oai_settings.groq_model}"`).attr('selected', true);
|
$(`#model_groq_select option[value="${oai_settings.groq_model}"`).attr('selected', true);
|
||||||
$('#model_01ai_select').val(oai_settings.zerooneai_model);
|
$('#model_01ai_select').val(oai_settings.zerooneai_model);
|
||||||
|
$('#model_blockentropy_select').val(oai_settings.blockentropy_model);
|
||||||
$('#custom_model_id').val(oai_settings.custom_model);
|
$('#custom_model_id').val(oai_settings.custom_model);
|
||||||
$('#custom_api_url_text').val(oai_settings.custom_url);
|
$('#custom_api_url_text').val(oai_settings.custom_url);
|
||||||
$('#openai_max_context').val(oai_settings.openai_max_context);
|
$('#openai_max_context').val(oai_settings.openai_max_context);
|
||||||
@ -3355,6 +3380,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
|||||||
perplexity_model: settings.perplexity_model,
|
perplexity_model: settings.perplexity_model,
|
||||||
groq_model: settings.groq_model,
|
groq_model: settings.groq_model,
|
||||||
zerooneai_model: settings.zerooneai_model,
|
zerooneai_model: settings.zerooneai_model,
|
||||||
|
blockentropy_model: settings.blockentropy_model,
|
||||||
custom_model: settings.custom_model,
|
custom_model: settings.custom_model,
|
||||||
custom_url: settings.custom_url,
|
custom_url: settings.custom_url,
|
||||||
custom_include_body: settings.custom_include_body,
|
custom_include_body: settings.custom_include_body,
|
||||||
@ -3795,6 +3821,7 @@ function onSettingsPresetChange() {
|
|||||||
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false],
|
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false],
|
||||||
groq_model: ['#model_groq_select', 'groq_model', false],
|
groq_model: ['#model_groq_select', 'groq_model', false],
|
||||||
zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false],
|
zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false],
|
||||||
|
blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false],
|
||||||
custom_model: ['#custom_model_id', 'custom_model', false],
|
custom_model: ['#custom_model_id', 'custom_model', false],
|
||||||
custom_url: ['#custom_api_url_text', 'custom_url', false],
|
custom_url: ['#custom_api_url_text', 'custom_url', false],
|
||||||
custom_include_body: ['#custom_include_body', 'custom_include_body', false],
|
custom_include_body: ['#custom_include_body', 'custom_include_body', false],
|
||||||
@ -4042,6 +4069,12 @@ async function onModelChange() {
|
|||||||
oai_settings.zerooneai_model = value;
|
oai_settings.zerooneai_model = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value && $(this).is('#model_blockentropy_select')) {
|
||||||
|
console.log('Block Entropy model changed to', value);
|
||||||
|
oai_settings.blockentropy_model = value;
|
||||||
|
$('#blockentropy_model_id').val(value).trigger('input');
|
||||||
|
}
|
||||||
|
|
||||||
if (value && $(this).is('#model_custom_select')) {
|
if (value && $(this).is('#model_custom_select')) {
|
||||||
console.log('Custom model changed to', value);
|
console.log('Custom model changed to', value);
|
||||||
oai_settings.custom_model = value;
|
oai_settings.custom_model = value;
|
||||||
@ -4330,6 +4363,29 @@ async function onModelChange() {
|
|||||||
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
|
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
|
||||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||||
}
|
}
|
||||||
|
if (oai_settings.chat_completion_source === chat_completion_sources.BLOCKENTROPY) {
|
||||||
|
if (oai_settings.max_context_unlocked) {
|
||||||
|
$('#openai_max_context').attr('max', unlocked_max);
|
||||||
|
}
|
||||||
|
else if (oai_settings.blockentropy_model.includes('llama3.1')) {
|
||||||
|
$('#openai_max_context').attr('max', max_16k);
|
||||||
|
}
|
||||||
|
else if (oai_settings.blockentropy_model.includes('72b')) {
|
||||||
|
$('#openai_max_context').attr('max', max_16k);
|
||||||
|
}
|
||||||
|
else if (oai_settings.blockentropy_model.includes('120b')) {
|
||||||
|
$('#openai_max_context').attr('max', max_12k);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#openai_max_context').attr('max', max_8k);
|
||||||
|
}
|
||||||
|
|
||||||
|
oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));
|
||||||
|
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||||
|
|
||||||
|
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
|
||||||
|
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||||
|
}
|
||||||
|
|
||||||
$('#openai_max_context_counter').attr('max', Number($('#openai_max_context').attr('max')));
|
$('#openai_max_context_counter').attr('max', Number($('#openai_max_context').attr('max')));
|
||||||
|
|
||||||
@ -4537,6 +4593,18 @@ async function onConnectButtonClick(e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) {
|
||||||
|
const api_key_blockentropy = String($('#api_key_blockentropy').val()).trim();
|
||||||
|
|
||||||
|
if (api_key_blockentropy.length) {
|
||||||
|
await writeSecret(SECRET_KEYS.BLOCKENTROPY, api_key_blockentropy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secret_state[SECRET_KEYS.BLOCKENTROPY]) {
|
||||||
|
console.log('No secret key saved for Block Entropy');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
startStatusLoading();
|
startStatusLoading();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
@ -4588,6 +4656,9 @@ function toggleChatCompletionForms() {
|
|||||||
else if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) {
|
else if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) {
|
||||||
$('#model_custom_select').trigger('change');
|
$('#model_custom_select').trigger('change');
|
||||||
}
|
}
|
||||||
|
else if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) {
|
||||||
|
$('#model_blockentropy_select').trigger('change');
|
||||||
|
}
|
||||||
$('[data-source]').each(function () {
|
$('[data-source]').each(function () {
|
||||||
const validSources = $(this).data('source').split(',');
|
const validSources = $(this).data('source').split(',');
|
||||||
$(this).toggle(validSources.includes(oai_settings.chat_completion_source));
|
$(this).toggle(validSources.includes(oai_settings.chat_completion_source));
|
||||||
@ -5317,6 +5388,7 @@ $(document).ready(async function () {
|
|||||||
$('#model_perplexity_select').on('change', onModelChange);
|
$('#model_perplexity_select').on('change', onModelChange);
|
||||||
$('#model_groq_select').on('change', onModelChange);
|
$('#model_groq_select').on('change', onModelChange);
|
||||||
$('#model_01ai_select').on('change', onModelChange);
|
$('#model_01ai_select').on('change', onModelChange);
|
||||||
|
$('#model_blockentropy_select').on('change', onModelChange);
|
||||||
$('#model_custom_select').on('change', onModelChange);
|
$('#model_custom_select').on('change', onModelChange);
|
||||||
$('#settings_preset_openai').on('change', onSettingsPresetChange);
|
$('#settings_preset_openai').on('change', onSettingsPresetChange);
|
||||||
$('#new_oai_preset').on('click', onNewPresetClick);
|
$('#new_oai_preset').on('click', onNewPresetClick);
|
||||||
|
@ -32,6 +32,7 @@ export const SECRET_KEYS = {
|
|||||||
ZEROONEAI: 'api_key_01ai',
|
ZEROONEAI: 'api_key_01ai',
|
||||||
HUGGINGFACE: 'api_key_huggingface',
|
HUGGINGFACE: 'api_key_huggingface',
|
||||||
STABILITY: 'api_key_stability',
|
STABILITY: 'api_key_stability',
|
||||||
|
BLOCKENTROPY: 'api_key_blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
const INPUT_MAP = {
|
const INPUT_MAP = {
|
||||||
@ -63,6 +64,7 @@ const INPUT_MAP = {
|
|||||||
[SECRET_KEYS.FEATHERLESS]: '#api_key_featherless',
|
[SECRET_KEYS.FEATHERLESS]: '#api_key_featherless',
|
||||||
[SECRET_KEYS.ZEROONEAI]: '#api_key_01ai',
|
[SECRET_KEYS.ZEROONEAI]: '#api_key_01ai',
|
||||||
[SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface',
|
[SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface',
|
||||||
|
[SECRET_KEYS.BLOCKENTROPY]: '#api_key_blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
async function clearSecret() {
|
async function clearSecret() {
|
||||||
|
@ -3249,6 +3249,7 @@ function getModelOptions() {
|
|||||||
{ id: 'model_perplexity_select', api: 'openai', type: chat_completion_sources.PERPLEXITY },
|
{ id: 'model_perplexity_select', api: 'openai', type: chat_completion_sources.PERPLEXITY },
|
||||||
{ id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ },
|
{ id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ },
|
||||||
{ id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI },
|
{ id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI },
|
||||||
|
{ id: 'model_blockentropy_select', api: 'openai', type: chat_completion_sources.BLOCKENTROPY },
|
||||||
{ id: 'model_novel_select', api: 'novel', type: null },
|
{ id: 'model_novel_select', api: 'novel', type: null },
|
||||||
{ id: 'horde_model', api: 'koboldhorde', type: null },
|
{ id: 'horde_model', api: 'koboldhorde', type: null },
|
||||||
];
|
];
|
||||||
|
@ -549,6 +549,15 @@ export function getTokenizerModel() {
|
|||||||
return yiTokenizer;
|
return yiTokenizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oai_settings.chat_completion_source === chat_completion_sources.BLOCKENTROPY) {
|
||||||
|
if (oai_settings.blockentropy_model.includes('llama3')) {
|
||||||
|
return llama3Tokenizer;
|
||||||
|
}
|
||||||
|
if (oai_settings.blockentropy_model.includes('miqu') || oai_settings.blockentropy_model.includes('mixtral')) {
|
||||||
|
return mistralTokenizer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Default to Turbo 3.5
|
// Default to Turbo 3.5
|
||||||
return turboTokenizer;
|
return turboTokenizer;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,7 @@ const CHAT_COMPLETION_SOURCES = {
|
|||||||
PERPLEXITY: 'perplexity',
|
PERPLEXITY: 'perplexity',
|
||||||
GROQ: 'groq',
|
GROQ: 'groq',
|
||||||
ZEROONEAI: '01ai',
|
ZEROONEAI: '01ai',
|
||||||
|
BLOCKENTROPY: 'blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ const API_PERPLEXITY = 'https://api.perplexity.ai';
|
|||||||
const API_GROQ = 'https://api.groq.com/openai/v1';
|
const API_GROQ = 'https://api.groq.com/openai/v1';
|
||||||
const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
|
const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
|
||||||
const API_01AI = 'https://api.01.ai/v1';
|
const API_01AI = 'https://api.01.ai/v1';
|
||||||
|
const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a post-processing step to the generated messages.
|
* Applies a post-processing step to the generated messages.
|
||||||
@ -675,6 +676,10 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
|
|||||||
api_url = API_01AI;
|
api_url = API_01AI;
|
||||||
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
||||||
headers = {};
|
headers = {};
|
||||||
|
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BLOCKENTROPY) {
|
||||||
|
api_url = API_BLOCKENTROPY;
|
||||||
|
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||||
|
headers = {};
|
||||||
} else {
|
} else {
|
||||||
console.log('This chat completion source is not supported yet.');
|
console.log('This chat completion source is not supported yet.');
|
||||||
return response_getstatus_openai.status(400).send({ error: true });
|
return response_getstatus_openai.status(400).send({ error: true });
|
||||||
@ -941,6 +946,11 @@ router.post('/generate', jsonParser, function (request, response) {
|
|||||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
||||||
headers = {};
|
headers = {};
|
||||||
bodyParams = {};
|
bodyParams = {};
|
||||||
|
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BLOCKENTROPY) {
|
||||||
|
apiUrl = API_BLOCKENTROPY;
|
||||||
|
apiKey = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||||
|
headers = {};
|
||||||
|
bodyParams = {};
|
||||||
} else {
|
} else {
|
||||||
console.log('This chat completion source is not supported yet.');
|
console.log('This chat completion source is not supported yet.');
|
||||||
return response.status(400).send({ error: true });
|
return response.status(400).send({ error: true });
|
||||||
|
@ -44,6 +44,7 @@ const SECRET_KEYS = {
|
|||||||
ZEROONEAI: 'api_key_01ai',
|
ZEROONEAI: 'api_key_01ai',
|
||||||
HUGGINGFACE: 'api_key_huggingface',
|
HUGGINGFACE: 'api_key_huggingface',
|
||||||
STABILITY: 'api_key_stability',
|
STABILITY: 'api_key_stability',
|
||||||
|
BLOCKENTROPY: 'api_key_blockentropy',
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are the keys that are safe to expose, even if allowKeysExposure is false
|
// These are the keys that are safe to expose, even if allowKeysExposure is false
|
||||||
|
@ -908,10 +908,94 @@ stability.post('/generate', jsonParser, async (request, response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const blockentropy = express.Router();
|
||||||
|
|
||||||
|
blockentropy.post('/models', jsonParser, async (request, response) => {
|
||||||
|
try {
|
||||||
|
const key = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
console.log('Block Entropy key not found.');
|
||||||
|
return response.sendStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelsResponse = await fetch('https://api.blockentropy.ai/sdapi/v1/sd-models', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${key}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!modelsResponse.ok) {
|
||||||
|
console.log('Block Entropy returned an error.');
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await modelsResponse.json();
|
||||||
|
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
console.log('Block Entropy returned invalid data.');
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
const models = data.map(x => ({ value: x.name, text: x.name }));
|
||||||
|
return response.send(models);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
blockentropy.post('/generate', jsonParser, async (request, response) => {
|
||||||
|
try {
|
||||||
|
const key = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
console.log('Block Entropy key not found.');
|
||||||
|
return response.sendStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Block Entropy request:', request.body);
|
||||||
|
|
||||||
|
const result = await fetch('https://api.blockentropy.ai/sdapi/v1/txt2img', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
prompt: request.body.prompt,
|
||||||
|
negative_prompt: request.body.negative_prompt,
|
||||||
|
model: request.body.model,
|
||||||
|
steps: request.body.steps,
|
||||||
|
width: request.body.width,
|
||||||
|
height: request.body.height,
|
||||||
|
// Random seed if negative.
|
||||||
|
seed: request.body.seed >= 0 ? request.body.seed : Math.floor(Math.random() * 10_000_000),
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `Bearer ${key}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.ok) {
|
||||||
|
console.log('Block Entropy returned an error.');
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await result.json();
|
||||||
|
console.log('Block Entropy response:', data);
|
||||||
|
|
||||||
|
return response.send(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
router.use('/comfy', comfy);
|
router.use('/comfy', comfy);
|
||||||
router.use('/together', together);
|
router.use('/together', together);
|
||||||
router.use('/drawthings', drawthings);
|
router.use('/drawthings', drawthings);
|
||||||
router.use('/pollinations', pollinations);
|
router.use('/pollinations', pollinations);
|
||||||
router.use('/stability', stability);
|
router.use('/stability', stability);
|
||||||
|
router.use('/blockentropy', blockentropy);
|
||||||
|
|
||||||
module.exports = { router };
|
module.exports = { router };
|
||||||
|
Reference in New Issue
Block a user