Merge branch 'staging' into no_updates_for_disabled_ext
| @@ -2745,7 +2745,6 @@ | |||
| 2745 | <optgroup> | 2745 | <optgroup> |
| 2746 | <option value="01ai">01.AI (Yi)</option> | 2746 | <option value="01ai">01.AI (Yi)</option> |
| 2747 | <option value="ai21">AI21</option> | 2747 | <option value="ai21">AI21</option> |
| 2748 | <option value="blockentropy">Block Entropy</option> | ||
| 2749 | <option value="claude">Claude</option> | 2748 | <option value="claude">Claude</option> |
| 2750 | <option value="cohere">Cohere</option> | 2749 | <option value="cohere">Cohere</option> |
| 2751 | <option value="deepseek">DeepSeek</option> | 2750 | <option value="deepseek">DeepSeek</option> |
| @@ -3375,20 +3374,6 @@ | |||
| 3375 | </select> | 3374 | </select> |
| 3376 | </div> | 3375 | </div> |
| 3377 | </form> | 3376 | </form> |
| 3378 | <form id="blockentropy_form" data-source="blockentropy"> | ||
| 3379 | <h4 data-i18n="Block Entropy API Key">Block Entropy API Key</h4> | ||
| 3380 | <div class="flex-container"> | ||
| 3381 | <input id="api_key_blockentropy" name="api_key_blockentropy" class="text_pole flex1" value="" type="text" autocomplete="off"> | ||
| 3382 | <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> | ||
| 3383 | </div> | ||
| 3384 | <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."> | ||
| 3385 | For privacy reasons, your API key will be hidden after you reload the page. | ||
| 3386 | </div> | ||
| 3387 | <h4 data-i18n="Select a Model">Select a Model</h4> | ||
| 3388 | <div class="flex-container"> | ||
| 3389 | <select id="model_blockentropy_select" class="text_pole"></select> | ||
| 3390 | </div> | ||
| 3391 | </form> | ||
| 3392 | <form id="custom_form" data-source="custom"> | 3377 | <form id="custom_form" data-source="custom"> |
| 3393 | <h4 data-i18n="Custom Endpoint (Base URL)">Custom Endpoint (Base URL)</h4> | 3378 | <h4 data-i18n="Custom Endpoint (Base URL)">Custom Endpoint (Base URL)</h4> |
| 3394 | <div class="flex-container"> | 3379 | <div class="flex-container"> |
| @@ -6101,8 +6086,11 @@ | |||
| 6101 | <label for="content "> | 6086 | <label for="content "> |
| 6102 | <small> | 6087 | <small> |
| 6103 | <span class="alignitemscenter flex-container flexnowrap wide100p justifySpaceBetween"> | 6088 | <span class="alignitemscenter flex-container flexnowrap wide100p justifySpaceBetween"> |
| 6104 | <span data-i18n="Content" class="alignitemscenter flex-container flexNoGap mdhotkey_location"> | 6089 | <span class="alignitemscenter flex-container"> |
| 6105 | Content | 6090 | <span data-i18n="Content" class="mdhotkey_location"> |
| 6091 | Content | ||
| 6092 | </span> | ||
| 6093 | <i class="editor_maximize fa-solid fa-maximize right_menu_button" title="Expand the editor" data-i18n="[title]Expand the editor"></i> | ||
| 6106 | </span> | 6094 | </span> |
| 6107 | <span> | 6095 | <span> |
| 6108 | (<span data-i18n="extension_token_counter">Tokens:</span> <span class="world_entry_form_token_counter" data-first-run="true">counting...</span>) | 6096 | (<span data-i18n="extension_token_counter">Tokens:</span> <span class="world_entry_form_token_counter" data-first-run="true">counting...</span>) |
| @@ -174,7 +174,7 @@ import { | |||
| 174 | saveBase64AsFile, | 174 | saveBase64AsFile, |
| 175 | uuidv4, | 175 | uuidv4, |
| 176 | } from './scripts/utils.js'; | 176 | } from './scripts/utils.js'; |
| 177 | import { debounce_timeout } from './scripts/constants.js'; | 177 | import { debounce_timeout, IGNORE_SYMBOL } from './scripts/constants.js'; |
| 178 | 178 | ||
| 179 | import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; | 179 | import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; |
| 180 | import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js'; | 180 | import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js'; |
| @@ -5301,6 +5301,12 @@ function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) { | |||
| 5301 | const itemName = chatItem.is_user ? chatItem['name'] : characterName; | 5301 | const itemName = chatItem.is_user ? chatItem['name'] : characterName; |
| 5302 | const shouldPrependName = !isNarratorType; | 5302 | const shouldPrependName = !isNarratorType; |
| 5303 | 5303 | ||
| 5304 | // If this symbol flag is set, completely ignore the message. | ||
| 5305 | // This can be used to hide messages without affecting the number of messages in the chat. | ||
| 5306 | if (chatItem.extra?.[IGNORE_SYMBOL]) { | ||
| 5307 | return ''; | ||
| 5308 | } | ||
| 5309 | |||
| 5304 | // Don't include a name if it's empty | 5310 | // Don't include a name if it's empty |
| 5305 | let textResult = chatItem?.name && shouldPrependName ? `${itemName}: ${chatItem.mes}\n` : `${chatItem.mes}\n`; | 5311 | let textResult = chatItem?.name && shouldPrependName ? `${itemName}: ${chatItem.mes}\n` : `${chatItem.mes}\n`; |
| 5306 | 5312 | ||
| @@ -407,7 +407,6 @@ function RA_autoconnect(PrevApi) { | |||
| 407 | || (secret_state[SECRET_KEYS.PERPLEXITY] && oai_settings.chat_completion_source == chat_completion_sources.PERPLEXITY) | 407 | || (secret_state[SECRET_KEYS.PERPLEXITY] && oai_settings.chat_completion_source == chat_completion_sources.PERPLEXITY) |
| 408 | || (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ) | 408 | || (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ) |
| 409 | || (secret_state[SECRET_KEYS.ZEROONEAI] && oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) | 409 | || (secret_state[SECRET_KEYS.ZEROONEAI] && oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) |
| 410 | || (secret_state[SECRET_KEYS.BLOCKENTROPY] && oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) | ||
| 411 | || (secret_state[SECRET_KEYS.NANOGPT] && oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) | 410 | || (secret_state[SECRET_KEYS.NANOGPT] && oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) |
| 412 | || (secret_state[SECRET_KEYS.DEEPSEEK] && oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) | 411 | || (secret_state[SECRET_KEYS.DEEPSEEK] && oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) |
| 413 | || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) | 412 | || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) |
| @@ -14,3 +14,11 @@ export const debounce_timeout = { | |||
| 14 | /** [5 sec] For delayed tasks, like auto-saving or completing batch operations that need a significant pause. */ | 14 | /** [5 sec] For delayed tasks, like auto-saving or completing batch operations that need a significant pause. */ |
| 15 | extended: 5000, | 15 | extended: 5000, |
| 16 | }; | 16 | }; |
| 17 | |||
| 18 | /** | ||
| 19 | * Used as an ephemeral key in message extra metadata. | ||
| 20 | * When set, the message will be excluded from generation | ||
| 21 | * prompts without affecting the number of chat messages, | ||
| 22 | * which is needed to preserve world info timed effects. | ||
| 23 | */ | ||
| 24 | export const IGNORE_SYMBOL = Symbol.for('ignore'); | ||
| @@ -77,7 +77,6 @@ const sources = { | |||
| 77 | drawthings: 'drawthings', | 77 | drawthings: 'drawthings', |
| 78 | pollinations: 'pollinations', | 78 | pollinations: 'pollinations', |
| 79 | stability: 'stability', | 79 | stability: 'stability', |
| 80 | blockentropy: 'blockentropy', | ||
| 81 | huggingface: 'huggingface', | 80 | huggingface: 'huggingface', |
| 82 | nanogpt: 'nanogpt', | 81 | nanogpt: 'nanogpt', |
| 83 | bfl: 'bfl', | 82 | bfl: 'bfl', |
| @@ -1300,7 +1299,6 @@ async function onModelChange() { | |||
| 1300 | sources.togetherai, | 1299 | sources.togetherai, |
| 1301 | sources.pollinations, | 1300 | sources.pollinations, |
| 1302 | sources.stability, | 1301 | sources.stability, |
| 1303 | sources.blockentropy, | ||
| 1304 | sources.huggingface, | 1302 | sources.huggingface, |
| 1305 | sources.nanogpt, | 1303 | sources.nanogpt, |
| 1306 | sources.bfl, | 1304 | sources.bfl, |
| @@ -1511,9 +1509,6 @@ async function loadSamplers() { | |||
| 1511 | case sources.stability: | 1509 | case sources.stability: |
| 1512 | samplers = ['N/A']; | 1510 | samplers = ['N/A']; |
| 1513 | break; | 1511 | break; |
| 1514 | case sources.blockentropy: | ||
| 1515 | samplers = ['N/A']; | ||
| 1516 | break; | ||
| 1517 | case sources.huggingface: | 1512 | case sources.huggingface: |
| 1518 | samplers = ['N/A']; | 1513 | samplers = ['N/A']; |
| 1519 | break; | 1514 | break; |
| @@ -1701,9 +1696,6 @@ async function loadModels() { | |||
| 1701 | case sources.stability: | 1696 | case sources.stability: |
| 1702 | models = await loadStabilityModels(); | 1697 | models = await loadStabilityModels(); |
| 1703 | break; | 1698 | break; |
| 1704 | case sources.blockentropy: | ||
| 1705 | models = await loadBlockEntropyModels(); | ||
| 1706 | break; | ||
| 1707 | case sources.huggingface: | 1699 | case sources.huggingface: |
| 1708 | models = [{ value: '', text: '<Enter Model ID above>' }]; | 1700 | models = [{ value: '', text: '<Enter Model ID above>' }]; |
| 1709 | break; | 1701 | break; |
| @@ -1799,26 +1791,6 @@ async function loadTogetherAIModels() { | |||
| 1799 | return []; | 1791 | return []; |
| 1800 | } | 1792 | } |
| 1801 | 1793 | ||
| 1802 | async function loadBlockEntropyModels() { | ||
| 1803 | if (!secret_state[SECRET_KEYS.BLOCKENTROPY]) { | ||
| 1804 | console.debug('Block Entropy API key is not set.'); | ||
| 1805 | return []; | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | const result = await fetch('/api/sd/blockentropy/models', { | ||
| 1809 | method: 'POST', | ||
| 1810 | headers: getRequestHeaders(), | ||
| 1811 | }); | ||
| 1812 | console.log(result); | ||
| 1813 | if (result.ok) { | ||
| 1814 | const data = await result.json(); | ||
| 1815 | console.log(data); | ||
| 1816 | return data; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | return []; | ||
| 1820 | } | ||
| 1821 | |||
| 1822 | async function loadNanoGPTModels() { | 1794 | async function loadNanoGPTModels() { |
| 1823 | if (!secret_state[SECRET_KEYS.NANOGPT]) { | 1795 | if (!secret_state[SECRET_KEYS.NANOGPT]) { |
| 1824 | console.debug('NanoGPT API key is not set.'); | 1796 | console.debug('NanoGPT API key is not set.'); |
| @@ -2097,9 +2069,6 @@ async function loadSchedulers() { | |||
| 2097 | case sources.stability: | 2069 | case sources.stability: |
| 2098 | schedulers = ['N/A']; | 2070 | schedulers = ['N/A']; |
| 2099 | break; | 2071 | break; |
| 2100 | case sources.blockentropy: | ||
| 2101 | schedulers = ['N/A']; | ||
| 2102 | break; | ||
| 2103 | case sources.huggingface: | 2072 | case sources.huggingface: |
| 2104 | schedulers = ['N/A']; | 2073 | schedulers = ['N/A']; |
| 2105 | break; | 2074 | break; |
| @@ -2188,9 +2157,6 @@ async function loadVaes() { | |||
| 2188 | case sources.stability: | 2157 | case sources.stability: |
| 2189 | vaes = ['N/A']; | 2158 | vaes = ['N/A']; |
| 2190 | break; | 2159 | break; |
| 2191 | case sources.blockentropy: | ||
| 2192 | vaes = ['N/A']; | ||
| 2193 | break; | ||
| 2194 | case sources.huggingface: | 2160 | case sources.huggingface: |
| 2195 | vaes = ['N/A']; | 2161 | vaes = ['N/A']; |
| 2196 | break; | 2162 | break; |
| @@ -2757,9 +2723,6 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP | |||
| 2757 | case sources.stability: | 2723 | case sources.stability: |
| 2758 | result = await generateStabilityImage(prefixedPrompt, negativePrompt, signal); | 2724 | result = await generateStabilityImage(prefixedPrompt, negativePrompt, signal); |
| 2759 | break; | 2725 | break; |
| 2760 | case sources.blockentropy: | ||
| 2761 | result = await generateBlockEntropyImage(prefixedPrompt, negativePrompt, signal); | ||
| 2762 | break; | ||
| 2763 | case sources.huggingface: | 2726 | case sources.huggingface: |
| 2764 | result = await generateHuggingFaceImage(prefixedPrompt, signal); | 2727 | result = await generateHuggingFaceImage(prefixedPrompt, signal); |
| 2765 | break; | 2728 | break; |
| @@ -2828,40 +2791,6 @@ async function generateTogetherAIImage(prompt, negativePrompt, signal) { | |||
| 2828 | } | 2791 | } |
| 2829 | } | 2792 | } |
| 2830 | 2793 | ||
| 2831 | async function generateBlockEntropyImage(prompt, negativePrompt, signal) { | ||
| 2832 | const result = await fetch('/api/sd/blockentropy/generate', { | ||
| 2833 | method: 'POST', | ||
| 2834 | headers: getRequestHeaders(), | ||
| 2835 | signal: signal, | ||
| 2836 | body: JSON.stringify({ | ||
| 2837 | prompt: prompt, | ||
| 2838 | negative_prompt: negativePrompt, | ||
| 2839 | model: extension_settings.sd.model, | ||
| 2840 | steps: extension_settings.sd.steps, | ||
| 2841 | width: extension_settings.sd.width, | ||
| 2842 | height: extension_settings.sd.height, | ||
| 2843 | seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined, | ||
| 2844 | }), | ||
| 2845 | }); | ||
| 2846 | |||
| 2847 | if (result.ok) { | ||
| 2848 | const data = await result.json(); | ||
| 2849 | |||
| 2850 | // Default format is 'jpg' | ||
| 2851 | let format = 'jpg'; | ||
| 2852 | |||
| 2853 | // Check if a format is specified in the result | ||
| 2854 | if (data.format) { | ||
| 2855 | format = data.format.toLowerCase(); | ||
| 2856 | } | ||
| 2857 | |||
| 2858 | return { format: format, data: data.images[0] }; | ||
| 2859 | } else { | ||
| 2860 | const text = await result.text(); | ||
| 2861 | throw new Error(text); | ||
| 2862 | } | ||
| 2863 | } | ||
| 2864 | |||
| 2865 | /** | 2794 | /** |
| 2866 | * Generates an image using the Pollinations API. | 2795 | * Generates an image using the Pollinations API. |
| 2867 | * @param {string} prompt - The main instruction used to guide the image generation. | 2796 | * @param {string} prompt - The main instruction used to guide the image generation. |
| @@ -3845,8 +3774,6 @@ function isValidState() { | |||
| 3845 | return true; | 3774 | return true; |
| 3846 | case sources.stability: | 3775 | case sources.stability: |
| 3847 | return secret_state[SECRET_KEYS.STABILITY]; | 3776 | return secret_state[SECRET_KEYS.STABILITY]; |
| 3848 | case sources.blockentropy: | ||
| 3849 | return secret_state[SECRET_KEYS.BLOCKENTROPY]; | ||
| 3850 | case sources.huggingface: | 3777 | case sources.huggingface: |
| 3851 | return secret_state[SECRET_KEYS.HUGGINGFACE]; | 3778 | return secret_state[SECRET_KEYS.HUGGINGFACE]; |
| 3852 | case sources.nanogpt: | 3779 | case sources.nanogpt: |
| @@ -38,7 +38,6 @@ | |||
| 38 | <label for="sd_source" data-i18n="Source">Source</label> | 38 | <label for="sd_source" data-i18n="Source">Source</label> |
| 39 | <select id="sd_source"> | 39 | <select id="sd_source"> |
| 40 | <option value="bfl">BFL (Black Forest Labs)</option> | 40 | <option value="bfl">BFL (Black Forest Labs)</option> |
| 41 | <option value="blockentropy">Block Entropy</option> | ||
| 42 | <option value="comfy">ComfyUI</option> | 41 | <option value="comfy">ComfyUI</option> |
| 43 | <option value="drawthings">DrawThings HTTP API</option> | 42 | <option value="drawthings">DrawThings HTTP API</option> |
| 44 | <option value="extras">Extras API (deprecated)</option> | 43 | <option value="extras">Extras API (deprecated)</option> |
| @@ -422,7 +421,7 @@ | |||
| 422 | </label> | 421 | </label> |
| 423 | </div> | 422 | </div> |
| 424 | 423 | ||
| 425 | <div data-sd-source="novel,togetherai,pollinations,comfy,drawthings,vlad,auto,horde,extras,stability,blockentropy,bfl" class="marginTop5"> | 424 | <div data-sd-source="novel,togetherai,pollinations,comfy,drawthings,vlad,auto,horde,extras,stability,bfl" class="marginTop5"> |
| 426 | <label for="sd_seed"> | 425 | <label for="sd_seed"> |
| 427 | <span data-i18n="Seed">Seed</span> | 426 | <span data-i18n="Seed">Seed</span> |
| 428 | <small data-i18n="(-1 for random)">(-1 for random)</small> | 427 | <small data-i18n="(-1 for random)">(-1 for random)</small> |
| @@ -75,6 +75,7 @@ import { Popup, POPUP_RESULT } from './popup.js'; | |||
| 75 | import { t } from './i18n.js'; | 75 | import { t } from './i18n.js'; |
| 76 | import { ToolManager } from './tool-calling.js'; | 76 | import { ToolManager } from './tool-calling.js'; |
| 77 | import { accountStorage } from './util/AccountStorage.js'; | 77 | import { accountStorage } from './util/AccountStorage.js'; |
| 78 | import { IGNORE_SYMBOL } from './constants.js'; | ||
| 78 | 79 | ||
| 79 | export { | 80 | export { |
| 80 | openai_messages_count, | 81 | openai_messages_count, |
| @@ -119,7 +120,6 @@ const default_bias_presets = { | |||
| 119 | const max_2k = 2047; | 120 | const max_2k = 2047; |
| 120 | const max_4k = 4095; | 121 | const max_4k = 4095; |
| 121 | const max_8k = 8191; | 122 | const max_8k = 8191; |
| 122 | const max_12k = 12287; | ||
| 123 | const max_16k = 16383; | 123 | const max_16k = 16383; |
| 124 | const max_32k = 32767; | 124 | const max_32k = 32767; |
| 125 | const max_64k = 65535; | 125 | const max_64k = 65535; |
| @@ -182,7 +182,6 @@ export const chat_completion_sources = { | |||
| 182 | PERPLEXITY: 'perplexity', | 182 | PERPLEXITY: 'perplexity', |
| 183 | GROQ: 'groq', | 183 | GROQ: 'groq', |
| 184 | ZEROONEAI: '01ai', | 184 | ZEROONEAI: '01ai', |
| 185 | BLOCKENTROPY: 'blockentropy', | ||
| 186 | NANOGPT: 'nanogpt', | 185 | NANOGPT: 'nanogpt', |
| 187 | DEEPSEEK: 'deepseek', | 186 | DEEPSEEK: 'deepseek', |
| 188 | }; | 187 | }; |
| @@ -258,7 +257,6 @@ export const settingsToUpdate = { | |||
| 258 | nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false], | 257 | nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false], |
| 259 | deepseek_model: ['#model_deepseek_select', 'deepseek_model', false], | 258 | deepseek_model: ['#model_deepseek_select', 'deepseek_model', false], |
| 260 | zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false], | 259 | zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false], |
| 261 | blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false], | ||
| 262 | custom_model: ['#custom_model_id', 'custom_model', false], | 260 | custom_model: ['#custom_model_id', 'custom_model', false], |
| 263 | custom_url: ['#custom_api_url_text', 'custom_url', false], | 261 | custom_url: ['#custom_api_url_text', 'custom_url', false], |
| 264 | custom_include_body: ['#custom_include_body', 'custom_include_body', false], | 262 | custom_include_body: ['#custom_include_body', 'custom_include_body', false], |
| @@ -346,7 +344,6 @@ const default_settings = { | |||
| 346 | groq_model: 'llama-3.3-70b-versatile', | 344 | groq_model: 'llama-3.3-70b-versatile', |
| 347 | nanogpt_model: 'gpt-4o-mini', | 345 | nanogpt_model: 'gpt-4o-mini', |
| 348 | zerooneai_model: 'yi-large', | 346 | zerooneai_model: 'yi-large', |
| 349 | blockentropy_model: 'be-70b-base-llama3.1', | ||
| 350 | deepseek_model: 'deepseek-chat', | 347 | deepseek_model: 'deepseek-chat', |
| 351 | custom_model: '', | 348 | custom_model: '', |
| 352 | custom_url: '', | 349 | custom_url: '', |
| @@ -427,7 +424,6 @@ const oai_settings = { | |||
| 427 | groq_model: 'llama-3.1-70b-versatile', | 424 | groq_model: 'llama-3.1-70b-versatile', |
| 428 | nanogpt_model: 'gpt-4o-mini', | 425 | nanogpt_model: 'gpt-4o-mini', |
| 429 | zerooneai_model: 'yi-large', | 426 | zerooneai_model: 'yi-large', |
| 430 | blockentropy_model: 'be-70b-base-llama3.1', | ||
| 431 | deepseek_model: 'deepseek-chat', | 427 | deepseek_model: 'deepseek-chat', |
| 432 | custom_model: '', | 428 | custom_model: '', |
| 433 | custom_url: '', | 429 | custom_url: '', |
| @@ -527,6 +523,13 @@ function setOpenAIMessages(chat) { | |||
| 527 | let role = chat[j]['is_user'] ? 'user' : 'assistant'; | 523 | let role = chat[j]['is_user'] ? 'user' : 'assistant'; |
| 528 | let content = chat[j]['mes']; | 524 | let content = chat[j]['mes']; |
| 529 | 525 | ||
| 526 | // If this symbol flag is set, completely ignore the message. | ||
| 527 | // This can be used to hide messages without affecting the number of messages in the chat. | ||
| 528 | if (chat[j].extra?.[IGNORE_SYMBOL]) { | ||
| 529 | j++; | ||
| 530 | continue; | ||
| 531 | } | ||
| 532 | |||
| 530 | // 100% legal way to send a message as system | 533 | // 100% legal way to send a message as system |
| 531 | if (chat[j].extra?.type === system_message_types.NARRATOR) { | 534 | if (chat[j].extra?.type === system_message_types.NARRATOR) { |
| 532 | role = 'system'; | 535 | role = 'system'; |
| @@ -1637,8 +1640,6 @@ export function getChatCompletionModel(source = null) { | |||
| 1637 | return oai_settings.groq_model; | 1640 | return oai_settings.groq_model; |
| 1638 | case chat_completion_sources.ZEROONEAI: | 1641 | case chat_completion_sources.ZEROONEAI: |
| 1639 | return oai_settings.zerooneai_model; | 1642 | return oai_settings.zerooneai_model; |
| 1640 | case chat_completion_sources.BLOCKENTROPY: | ||
| 1641 | return oai_settings.blockentropy_model; | ||
| 1642 | case chat_completion_sources.NANOGPT: | 1643 | case chat_completion_sources.NANOGPT: |
| 1643 | return oai_settings.nanogpt_model; | 1644 | return oai_settings.nanogpt_model; |
| 1644 | case chat_completion_sources.DEEPSEEK: | 1645 | case chat_completion_sources.DEEPSEEK: |
| @@ -1757,23 +1758,6 @@ function saveModelList(data) { | |||
| 1757 | $('#model_01ai_select').val(oai_settings.zerooneai_model).trigger('change'); | 1758 | $('#model_01ai_select').val(oai_settings.zerooneai_model).trigger('change'); |
| 1758 | } | 1759 | } |
| 1759 | 1760 | ||
| 1760 | if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) { | ||
| 1761 | $('#model_blockentropy_select').empty(); | ||
| 1762 | model_list.forEach((model) => { | ||
| 1763 | $('#model_blockentropy_select').append( | ||
| 1764 | $('<option>', { | ||
| 1765 | value: model.id, | ||
| 1766 | text: model.id, | ||
| 1767 | })); | ||
| 1768 | }); | ||
| 1769 | |||
| 1770 | if (!oai_settings.blockentropy_model && model_list.length > 0) { | ||
| 1771 | oai_settings.blockentropy_model = model_list[0].id; | ||
| 1772 | } | ||
| 1773 | |||
| 1774 | $('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change'); | ||
| 1775 | } | ||
| 1776 | |||
| 1777 | if (oai_settings.chat_completion_source == chat_completion_sources.MISTRALAI) { | 1761 | if (oai_settings.chat_completion_source == chat_completion_sources.MISTRALAI) { |
| 1778 | /** @type {HTMLSelectElement} */ | 1762 | /** @type {HTMLSelectElement} */ |
| 1779 | const mistralModelSelect = document.querySelector('#model_mistralai_select'); | 1763 | const mistralModelSelect = document.querySelector('#model_mistralai_select'); |
| @@ -3246,7 +3230,6 @@ function loadOpenAISettings(data, settings) { | |||
| 3246 | oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model; | 3230 | oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model; |
| 3247 | oai_settings.nanogpt_model = settings.nanogpt_model ?? default_settings.nanogpt_model; | 3231 | oai_settings.nanogpt_model = settings.nanogpt_model ?? default_settings.nanogpt_model; |
| 3248 | oai_settings.deepseek_model = settings.deepseek_model ?? default_settings.deepseek_model; | 3232 | oai_settings.deepseek_model = settings.deepseek_model ?? default_settings.deepseek_model; |
| 3249 | oai_settings.blockentropy_model = settings.blockentropy_model ?? default_settings.blockentropy_model; | ||
| 3250 | oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model; | 3233 | oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model; |
| 3251 | oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model; | 3234 | oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model; |
| 3252 | oai_settings.custom_url = settings.custom_url ?? default_settings.custom_url; | 3235 | oai_settings.custom_url = settings.custom_url ?? default_settings.custom_url; |
| @@ -3333,7 +3316,6 @@ function loadOpenAISettings(data, settings) { | |||
| 3333 | $('#model_deepseek_select').val(oai_settings.deepseek_model); | 3316 | $('#model_deepseek_select').val(oai_settings.deepseek_model); |
| 3334 | $(`#model_deepseek_select option[value="${oai_settings.deepseek_model}"`).prop('selected', true); | 3317 | $(`#model_deepseek_select option[value="${oai_settings.deepseek_model}"`).prop('selected', true); |
| 3335 | $('#model_01ai_select').val(oai_settings.zerooneai_model); | 3318 | $('#model_01ai_select').val(oai_settings.zerooneai_model); |
| 3336 | $('#model_blockentropy_select').val(oai_settings.blockentropy_model); | ||
| 3337 | $('#custom_model_id').val(oai_settings.custom_model); | 3319 | $('#custom_model_id').val(oai_settings.custom_model); |
| 3338 | $('#custom_api_url_text').val(oai_settings.custom_url); | 3320 | $('#custom_api_url_text').val(oai_settings.custom_url); |
| 3339 | $('#openai_max_context').val(oai_settings.openai_max_context); | 3321 | $('#openai_max_context').val(oai_settings.openai_max_context); |
| @@ -3613,7 +3595,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) { | |||
| 3613 | perplexity_model: settings.perplexity_model, | 3595 | perplexity_model: settings.perplexity_model, |
| 3614 | groq_model: settings.groq_model, | 3596 | groq_model: settings.groq_model, |
| 3615 | zerooneai_model: settings.zerooneai_model, | 3597 | zerooneai_model: settings.zerooneai_model, |
| 3616 | blockentropy_model: settings.blockentropy_model, | ||
| 3617 | custom_model: settings.custom_model, | 3598 | custom_model: settings.custom_model, |
| 3618 | custom_url: settings.custom_url, | 3599 | custom_url: settings.custom_url, |
| 3619 | custom_include_body: settings.custom_include_body, | 3600 | custom_include_body: settings.custom_include_body, |
| @@ -4322,12 +4303,6 @@ async function onModelChange() { | |||
| 4322 | oai_settings.zerooneai_model = value; | 4303 | oai_settings.zerooneai_model = value; |
| 4323 | } | 4304 | } |
| 4324 | 4305 | ||
| 4325 | if (value && $(this).is('#model_blockentropy_select')) { | ||
| 4326 | console.log('Block Entropy model changed to', value); | ||
| 4327 | oai_settings.blockentropy_model = value; | ||
| 4328 | $('#blockentropy_model_id').val(value).trigger('input'); | ||
| 4329 | } | ||
| 4330 | |||
| 4331 | if (value && $(this).is('#model_custom_select')) { | 4306 | if (value && $(this).is('#model_custom_select')) { |
| 4332 | console.log('Custom model changed to', value); | 4307 | console.log('Custom model changed to', value); |
| 4333 | oai_settings.custom_model = value; | 4308 | oai_settings.custom_model = value; |
| @@ -4577,29 +4552,6 @@ async function onModelChange() { | |||
| 4577 | oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); | 4552 | oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); |
| 4578 | $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); | 4553 | $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); |
| 4579 | } | 4554 | } |
| 4580 | if (oai_settings.chat_completion_source === chat_completion_sources.BLOCKENTROPY) { | ||
| 4581 | if (oai_settings.max_context_unlocked) { | ||
| 4582 | $('#openai_max_context').attr('max', unlocked_max); | ||
| 4583 | } | ||
| 4584 | else if (oai_settings.blockentropy_model.includes('llama3.1')) { | ||
| 4585 | $('#openai_max_context').attr('max', max_16k); | ||
| 4586 | } | ||
| 4587 | else if (oai_settings.blockentropy_model.includes('72b')) { | ||
| 4588 | $('#openai_max_context').attr('max', max_16k); | ||
| 4589 | } | ||
| 4590 | else if (oai_settings.blockentropy_model.includes('120b')) { | ||
| 4591 | $('#openai_max_context').attr('max', max_12k); | ||
| 4592 | } | ||
| 4593 | else { | ||
| 4594 | $('#openai_max_context').attr('max', max_8k); | ||
| 4595 | } | ||
| 4596 | |||
| 4597 | oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); | ||
| 4598 | $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); | ||
| 4599 | |||
| 4600 | oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); | ||
| 4601 | $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); | ||
| 4602 | } | ||
| 4603 | 4555 | ||
| 4604 | if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) { | 4556 | if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) { |
| 4605 | if (oai_settings.max_context_unlocked) { | 4557 | if (oai_settings.max_context_unlocked) { |
| @@ -4866,18 +4818,6 @@ async function onConnectButtonClick(e) { | |||
| 4866 | return; | 4818 | return; |
| 4867 | } | 4819 | } |
| 4868 | } | 4820 | } |
| 4869 | if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) { | ||
| 4870 | const api_key_blockentropy = String($('#api_key_blockentropy').val()).trim(); | ||
| 4871 | |||
| 4872 | if (api_key_blockentropy.length) { | ||
| 4873 | await writeSecret(SECRET_KEYS.BLOCKENTROPY, api_key_blockentropy); | ||
| 4874 | } | ||
| 4875 | |||
| 4876 | if (!secret_state[SECRET_KEYS.BLOCKENTROPY]) { | ||
| 4877 | console.log('No secret key saved for Block Entropy'); | ||
| 4878 | return; | ||
| 4879 | } | ||
| 4880 | } | ||
| 4881 | 4821 | ||
| 4882 | startStatusLoading(); | 4822 | startStatusLoading(); |
| 4883 | saveSettingsDebounced(); | 4823 | saveSettingsDebounced(); |
| @@ -4932,9 +4872,6 @@ function toggleChatCompletionForms() { | |||
| 4932 | else if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) { | 4872 | else if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) { |
| 4933 | $('#model_custom_select').trigger('change'); | 4873 | $('#model_custom_select').trigger('change'); |
| 4934 | } | 4874 | } |
| 4935 | else if (oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) { | ||
| 4936 | $('#model_blockentropy_select').trigger('change'); | ||
| 4937 | } | ||
| 4938 | else if (oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) { | 4875 | else if (oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) { |
| 4939 | $('#model_deepseek_select').trigger('change'); | 4876 | $('#model_deepseek_select').trigger('change'); |
| 4940 | } | 4877 | } |
| @@ -5687,7 +5624,6 @@ export function initOpenAI() { | |||
| 5687 | $('#model_nanogpt_select').on('change', onModelChange); | 5624 | $('#model_nanogpt_select').on('change', onModelChange); |
| 5688 | $('#model_deepseek_select').on('change', onModelChange); | 5625 | $('#model_deepseek_select').on('change', onModelChange); |
| 5689 | $('#model_01ai_select').on('change', onModelChange); | 5626 | $('#model_01ai_select').on('change', onModelChange); |
| 5690 | $('#model_blockentropy_select').on('change', onModelChange); | ||
| 5691 | $('#model_custom_select').on('change', onModelChange); | 5627 | $('#model_custom_select').on('change', onModelChange); |
| 5692 | $('#settings_preset_openai').on('change', onSettingsPresetChange); | 5628 | $('#settings_preset_openai').on('change', onSettingsPresetChange); |
| 5693 | $('#new_oai_preset').on('click', onNewPresetClick); | 5629 | $('#new_oai_preset').on('click', onNewPresetClick); |
| @@ -34,7 +34,6 @@ export const SECRET_KEYS = { | |||
| 34 | ZEROONEAI: 'api_key_01ai', | 34 | ZEROONEAI: 'api_key_01ai', |
| 35 | HUGGINGFACE: 'api_key_huggingface', | 35 | HUGGINGFACE: 'api_key_huggingface', |
| 36 | STABILITY: 'api_key_stability', | 36 | STABILITY: 'api_key_stability', |
| 37 | BLOCKENTROPY: 'api_key_blockentropy', | ||
| 38 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', | 37 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 39 | NANOGPT: 'api_key_nanogpt', | 38 | NANOGPT: 'api_key_nanogpt', |
| 40 | TAVILY: 'api_key_tavily', | 39 | TAVILY: 'api_key_tavily', |
| @@ -74,7 +73,6 @@ const INPUT_MAP = { | |||
| 74 | [SECRET_KEYS.FEATHERLESS]: '#api_key_featherless', | 73 | [SECRET_KEYS.FEATHERLESS]: '#api_key_featherless', |
| 75 | [SECRET_KEYS.ZEROONEAI]: '#api_key_01ai', | 74 | [SECRET_KEYS.ZEROONEAI]: '#api_key_01ai', |
| 76 | [SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface', | 75 | [SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface', |
| 77 | [SECRET_KEYS.BLOCKENTROPY]: '#api_key_blockentropy', | ||
| 78 | [SECRET_KEYS.NANOGPT]: '#api_key_nanogpt', | 76 | [SECRET_KEYS.NANOGPT]: '#api_key_nanogpt', |
| 79 | [SECRET_KEYS.GENERIC]: '#api_key_generic', | 77 | [SECRET_KEYS.GENERIC]: '#api_key_generic', |
| 80 | [SECRET_KEYS.DEEPSEEK]: '#api_key_deepseek', | 78 | [SECRET_KEYS.DEEPSEEK]: '#api_key_deepseek', |
| @@ -3936,7 +3936,6 @@ function getModelOptions(quiet) { | |||
| 3936 | { id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ }, | 3936 | { id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ }, |
| 3937 | { id: 'model_nanogpt_select', api: 'openai', type: chat_completion_sources.NANOGPT }, | 3937 | { id: 'model_nanogpt_select', api: 'openai', type: chat_completion_sources.NANOGPT }, |
| 3938 | { id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI }, | 3938 | { id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI }, |
| 3939 | { id: 'model_blockentropy_select', api: 'openai', type: chat_completion_sources.BLOCKENTROPY }, | ||
| 3940 | { id: 'model_deepseek_select', api: 'openai', type: chat_completion_sources.DEEPSEEK }, | 3939 | { id: 'model_deepseek_select', api: 'openai', type: chat_completion_sources.DEEPSEEK }, |
| 3941 | { id: 'model_novel_select', api: 'novel', type: null }, | 3940 | { id: 'model_novel_select', api: 'novel', type: null }, |
| 3942 | { id: 'horde_model', api: 'koboldhorde', type: null }, | 3941 | { id: 'horde_model', api: 'koboldhorde', type: null }, |
| @@ -83,6 +83,7 @@ import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, | |||
| 83 | import { ChatCompletionService, TextCompletionService } from './custom-request.js'; | 83 | import { ChatCompletionService, TextCompletionService } from './custom-request.js'; |
| 84 | import { ConnectionManagerRequestService } from './extensions/shared.js'; | 84 | import { ConnectionManagerRequestService } from './extensions/shared.js'; |
| 85 | import { updateReasoningUI, parseReasoningFromString } from './reasoning.js'; | 85 | import { updateReasoningUI, parseReasoningFromString } from './reasoning.js'; |
| 86 | import { IGNORE_SYMBOL } from './constants.js'; | ||
| 86 | 87 | ||
| 87 | export function getContext() { | 88 | export function getContext() { |
| 88 | return { | 89 | return { |
| @@ -225,6 +226,9 @@ export function getContext() { | |||
| 225 | parseReasoningFromString, | 226 | parseReasoningFromString, |
| 226 | unshallowCharacter, | 227 | unshallowCharacter, |
| 227 | unshallowGroupMembers, | 228 | unshallowGroupMembers, |
| 229 | symbols: { | ||
| 230 | ignore: IGNORE_SYMBOL, | ||
| 231 | }, | ||
| 228 | }; | 232 | }; |
| 229 | } | 233 | } |
| 230 | 234 | ||
| @@ -729,15 +729,6 @@ export function getTokenizerModel() { | |||
| 729 | return yiTokenizer; | 729 | return yiTokenizer; |
| 730 | } | 730 | } |
| 731 | 731 | ||
| 732 | if (oai_settings.chat_completion_source === chat_completion_sources.BLOCKENTROPY) { | ||
| 733 | if (oai_settings.blockentropy_model.includes('llama3')) { | ||
| 734 | return llama3Tokenizer; | ||
| 735 | } | ||
| 736 | if (oai_settings.blockentropy_model.includes('miqu') || oai_settings.blockentropy_model.includes('mixtral')) { | ||
| 737 | return mistralTokenizer; | ||
| 738 | } | ||
| 739 | } | ||
| 740 | |||
| 741 | // Default to Turbo 3.5 | 732 | // Default to Turbo 3.5 |
| 742 | return turboTokenizer; | 733 | return turboTokenizer; |
| 743 | } | 734 | } |
| @@ -2680,8 +2680,10 @@ export async function getWorldEntry(name, data, entry) { | |||
| 2680 | $(counter).text(numberOfTokens); | 2680 | $(counter).text(numberOfTokens); |
| 2681 | }, debounce_timeout.relaxed); | 2681 | }, debounce_timeout.relaxed); |
| 2682 | 2682 | ||
| 2683 | const contentInputId = `world_entry_content_${entry.uid}`; | ||
| 2683 | const contentInput = template.find('textarea[name="content"]'); | 2684 | const contentInput = template.find('textarea[name="content"]'); |
| 2684 | contentInput.data('uid', entry.uid); | 2685 | contentInput.data('uid', entry.uid); |
| 2686 | contentInput.attr('id', contentInputId); | ||
| 2685 | contentInput.on('input', async function (_, { skipCount } = {}) { | 2687 | contentInput.on('input', async function (_, { skipCount } = {}) { |
| 2686 | const uid = $(this).data('uid'); | 2688 | const uid = $(this).data('uid'); |
| 2687 | const value = $(this).val(); | 2689 | const value = $(this).val(); |
| @@ -2698,7 +2700,9 @@ export async function getWorldEntry(name, data, entry) { | |||
| 2698 | countTokensDebounced(counter, value); | 2700 | countTokensDebounced(counter, value); |
| 2699 | }); | 2701 | }); |
| 2700 | contentInput.val(entry.content).trigger('input', { skipCount: true }); | 2702 | contentInput.val(entry.content).trigger('input', { skipCount: true }); |
| 2701 | //initScrollHeight(contentInput); | 2703 | |
| 2704 | const contentExpandButton = template.find('.editor_maximize'); | ||
| 2705 | contentExpandButton.attr('data-for', contentInputId); | ||
| 2702 | 2706 | ||
| 2703 | template.find('.inline-drawer-toggle').on('click', function () { | 2707 | template.find('.inline-drawer-toggle').on('click', function () { |
| 2704 | if (counter.data('first-run')) { | 2708 | if (counter.data('first-run')) { |
| @@ -174,7 +174,6 @@ export const CHAT_COMPLETION_SOURCES = { | |||
| 174 | PERPLEXITY: 'perplexity', | 174 | PERPLEXITY: 'perplexity', |
| 175 | GROQ: 'groq', | 175 | GROQ: 'groq', |
| 176 | ZEROONEAI: '01ai', | 176 | ZEROONEAI: '01ai', |
| 177 | BLOCKENTROPY: 'blockentropy', | ||
| 178 | NANOGPT: 'nanogpt', | 177 | NANOGPT: 'nanogpt', |
| 179 | DEEPSEEK: 'deepseek', | 178 | DEEPSEEK: 'deepseek', |
| 180 | }; | 179 | }; |
| @@ -50,7 +50,6 @@ const API_PERPLEXITY = 'https://api.perplexity.ai'; | |||
| 50 | const API_GROQ = 'https://api.groq.com/openai/v1'; | 50 | const API_GROQ = 'https://api.groq.com/openai/v1'; |
| 51 | const API_MAKERSUITE = 'https://generativelanguage.googleapis.com'; | 51 | const API_MAKERSUITE = 'https://generativelanguage.googleapis.com'; |
| 52 | const API_01AI = 'https://api.lingyiwanwu.com/v1'; | 52 | const API_01AI = 'https://api.lingyiwanwu.com/v1'; |
| 53 | const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1'; | ||
| 54 | const API_AI21 = 'https://api.ai21.com/studio/v1'; | 53 | const API_AI21 = 'https://api.ai21.com/studio/v1'; |
| 55 | const API_NANOGPT = 'https://nano-gpt.com/api/v1'; | 54 | const API_NANOGPT = 'https://nano-gpt.com/api/v1'; |
| 56 | const API_DEEPSEEK = 'https://api.deepseek.com/beta'; | 55 | const API_DEEPSEEK = 'https://api.deepseek.com/beta'; |
| @@ -865,10 +864,6 @@ router.post('/status', async function (request, response_getstatus_openai) { | |||
| 865 | api_url = API_01AI; | 864 | api_url = API_01AI; |
| 866 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); | 865 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); |
| 867 | headers = {}; | 866 | headers = {}; |
| 868 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BLOCKENTROPY) { | ||
| 869 | api_url = API_BLOCKENTROPY; | ||
| 870 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); | ||
| 871 | headers = {}; | ||
| 872 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | 867 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { |
| 873 | api_url = API_NANOGPT; | 868 | api_url = API_NANOGPT; |
| 874 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | 869 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); |
| @@ -1155,11 +1150,6 @@ router.post('/generate', function (request, response) { | |||
| 1155 | apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); | 1150 | apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); |
| 1156 | headers = {}; | 1151 | headers = {}; |
| 1157 | bodyParams = {}; | 1152 | bodyParams = {}; |
| 1158 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.BLOCKENTROPY) { | ||
| 1159 | apiUrl = API_BLOCKENTROPY; | ||
| 1160 | apiKey = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); | ||
| 1161 | headers = {}; | ||
| 1162 | bodyParams = {}; | ||
| 1163 | } else { | 1153 | } else { |
| 1164 | console.warn('This chat completion source is not supported yet.'); | 1154 | console.warn('This chat completion source is not supported yet.'); |
| 1165 | return response.status(400).send({ error: true }); | 1155 | return response.status(400).send({ error: true }); |
| @@ -44,7 +44,6 @@ export const SECRET_KEYS = { | |||
| 44 | ZEROONEAI: 'api_key_01ai', | 44 | ZEROONEAI: 'api_key_01ai', |
| 45 | HUGGINGFACE: 'api_key_huggingface', | 45 | HUGGINGFACE: 'api_key_huggingface', |
| 46 | STABILITY: 'api_key_stability', | 46 | STABILITY: 'api_key_stability', |
| 47 | BLOCKENTROPY: 'api_key_blockentropy', | ||
| 48 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', | 47 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 49 | TAVILY: 'api_key_tavily', | 48 | TAVILY: 'api_key_tavily', |
| 50 | NANOGPT: 'api_key_nanogpt', | 49 | NANOGPT: 'api_key_nanogpt', |
| @@ -907,89 +907,6 @@ stability.post('/generate', async (request, response) => { | |||
| 907 | } | 907 | } |
| 908 | }); | 908 | }); |
| 909 | 909 | ||
| 910 | const blockentropy = express.Router(); | ||
| 911 | |||
| 912 | blockentropy.post('/models', async (request, response) => { | ||
| 913 | try { | ||
| 914 | const key = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); | ||
| 915 | |||
| 916 | if (!key) { | ||
| 917 | console.warn('Block Entropy key not found.'); | ||
| 918 | return response.sendStatus(400); | ||
| 919 | } | ||
| 920 | |||
| 921 | const modelsResponse = await fetch('https://api.blockentropy.ai/sdapi/v1/sd-models', { | ||
| 922 | method: 'GET', | ||
| 923 | headers: { | ||
| 924 | 'Authorization': `Bearer ${key}`, | ||
| 925 | }, | ||
| 926 | }); | ||
| 927 | |||
| 928 | if (!modelsResponse.ok) { | ||
| 929 | console.warn('Block Entropy returned an error.'); | ||
| 930 | return response.sendStatus(500); | ||
| 931 | } | ||
| 932 | |||
| 933 | const data = await modelsResponse.json(); | ||
| 934 | |||
| 935 | if (!Array.isArray(data)) { | ||
| 936 | console.warn('Block Entropy returned invalid data.'); | ||
| 937 | return response.sendStatus(500); | ||
| 938 | } | ||
| 939 | const models = data.map(x => ({ value: x.name, text: x.name })); | ||
| 940 | return response.send(models); | ||
| 941 | |||
| 942 | } catch (error) { | ||
| 943 | console.error(error); | ||
| 944 | return response.sendStatus(500); | ||
| 945 | } | ||
| 946 | }); | ||
| 947 | |||
| 948 | blockentropy.post('/generate', async (request, response) => { | ||
| 949 | try { | ||
| 950 | const key = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); | ||
| 951 | |||
| 952 | if (!key) { | ||
| 953 | console.warn('Block Entropy key not found.'); | ||
| 954 | return response.sendStatus(400); | ||
| 955 | } | ||
| 956 | |||
| 957 | console.debug('Block Entropy request:', request.body); | ||
| 958 | |||
| 959 | const result = await fetch('https://api.blockentropy.ai/sdapi/v1/txt2img', { | ||
| 960 | method: 'POST', | ||
| 961 | body: JSON.stringify({ | ||
| 962 | prompt: request.body.prompt, | ||
| 963 | negative_prompt: request.body.negative_prompt, | ||
| 964 | model: request.body.model, | ||
| 965 | steps: request.body.steps, | ||
| 966 | width: request.body.width, | ||
| 967 | height: request.body.height, | ||
| 968 | // Random seed if negative. | ||
| 969 | seed: request.body.seed >= 0 ? request.body.seed : Math.floor(Math.random() * 10_000_000), | ||
| 970 | }), | ||
| 971 | headers: { | ||
| 972 | 'Content-Type': 'application/json', | ||
| 973 | 'Authorization': `Bearer ${key}`, | ||
| 974 | }, | ||
| 975 | }); | ||
| 976 | |||
| 977 | if (!result.ok) { | ||
| 978 | console.warn('Block Entropy returned an error.'); | ||
| 979 | return response.sendStatus(500); | ||
| 980 | } | ||
| 981 | |||
| 982 | const data = await result.json(); | ||
| 983 | console.debug('Block Entropy response:', data); | ||
| 984 | |||
| 985 | return response.send(data); | ||
| 986 | } catch (error) { | ||
| 987 | console.error(error); | ||
| 988 | return response.sendStatus(500); | ||
| 989 | } | ||
| 990 | }); | ||
| 991 | |||
| 992 | |||
| 993 | const huggingface = express.Router(); | 910 | const huggingface = express.Router(); |
| 994 | 911 | ||
| 995 | huggingface.post('/generate', async (request, response) => { | 912 | huggingface.post('/generate', async (request, response) => { |
| @@ -1358,7 +1275,6 @@ router.use('/together', together); | |||
| 1358 | router.use('/drawthings', drawthings); | 1275 | router.use('/drawthings', drawthings); |
| 1359 | router.use('/pollinations', pollinations); | 1276 | router.use('/pollinations', pollinations); |
| 1360 | router.use('/stability', stability); | 1277 | router.use('/stability', stability); |
| 1361 | router.use('/blockentropy', blockentropy); | ||
| 1362 | router.use('/huggingface', huggingface); | 1278 | router.use('/huggingface', huggingface); |
| 1363 | router.use('/nanogpt', nanogpt); | 1279 | router.use('/nanogpt', nanogpt); |
| 1364 | router.use('/bfl', bfl); | 1280 | router.use('/bfl', bfl); |