From 97096add2a5f9309e32b923ee08489e6b1a366d6 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 23 Jul 2024 21:44:48 +0200 Subject: [PATCH 001/165] Utility css class to auto-select input/textarea - Add an event listener on document level that checks for focus events on input/textarea controls. If they have the class "auto-select" the content will be auto-selected --- public/script.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/script.js b/public/script.js index dd6af9884..de922428c 100644 --- a/public/script.js +++ b/public/script.js @@ -10647,6 +10647,14 @@ jQuery(async function () { $(document).on('click', '.open_alternate_greetings', openAlternateGreetings); /* $('#set_character_world').on('click', openCharacterWorldPopup); */ + $(document).on('focus', 'input.auto-select, textarea.auto-select', function () { + const control = $(this)[0]; + if (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) { + control.select(); + console.debug('Auto-selecting content of input control', control); + } + }); + $(document).keyup(function (e) { if (e.key === 'Escape') { const isEditVisible = $('#curEditTextarea').is(':visible'); From 7d2c0a8824236f6785b9c11978b860a7bc6edecc Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 23 Jul 2024 21:48:24 +0200 Subject: [PATCH 002/165] Update popup input field to use auto-select --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index e05c6e526..93a7d4750 100644 --- a/public/index.html +++ b/public/index.html @@ -4896,7 +4896,7 @@ - + `; - const blocks = page.map(entry => getWorldEntry(name, data, entry)).filter(x => x); + const blocksPromises = page.map(async (entry) => await getWorldEntry(name, data, entry)).filter(x => x); + const blocks = await Promise.all(blocksPromises); const isCustomOrder = $('#world_info_sort_order').find(':selected').data('rule') === 'custom'; if (!isCustomOrder) { blocks.forEach(block => { @@ -2251,7 +2252,7 @@ function parseRegexFromString(input) { } } -function getWorldEntry(name, data, entry) { +async function getWorldEntry(name, data, entry) { if (!data.entries[entry.uid]) { return; } From 7c764264f4de6f0ae2d6ceaec5e0a6bc7f181a42 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Mon, 5 Aug 2024 03:29:29 +0200 Subject: [PATCH 006/165] Make WI entry drag handle not selectable --- public/style.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/style.css b/public/style.css index 2e828234d..9ad5f098a 100644 --- a/public/style.css +++ b/public/style.css @@ -3429,6 +3429,8 @@ grammarly-extension { .drag-handle { cursor: grab; + /* Make the drag handle not selectable in most browsers */ + user-select: none; } #form_rename_chat { From bc9eb080e5dbf0668d9e2655ad2f81f928dc41fb Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Mon, 5 Aug 2024 07:53:24 +0200 Subject: [PATCH 007/165] Cannot recalc scrollHeight before resetting it - Fixed Ross' fuck-up. You can thank me later --- public/scripts/utils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 39336b1cb..12e3716ab 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -498,9 +498,8 @@ export function restoreCaretPosition(element, position) { } export async function resetScrollHeight(element) { - let scrollHeight = $(element).prop('scrollHeight'); $(element).css('height', '0px'); - $(element).css('height', scrollHeight + 3 + 'px'); + $(element).css('height', $(element).prop('scrollHeight') + 3 + 'px'); } /** From 6637bc305297d9e2f46196fc0ac60b9232d1d794 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:22:40 +0300 Subject: [PATCH 008/165] Emit events on caption and SD image messages --- public/scripts/extensions/caption/index.js | 4 ++++ public/scripts/extensions/stable-diffusion/index.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions/caption/index.js b/public/scripts/extensions/caption/index.js index b2e8c7664..7194abc49 100644 --- a/public/scripts/extensions/caption/index.js +++ b/public/scripts/extensions/caption/index.js @@ -169,7 +169,11 @@ async function sendCaptionedMessage(caption, image) { }, }; context.chat.push(message); + const messageId = context.chat.length - 1; + await eventSource.emit(event_types.MESSAGE_SENT, messageId); context.addOneMessage(message); + await eventSource.emit(event_types.USER_MESSAGE_RENDERED, messageId); + await context.saveChat(); } /** diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index 4d2c35722..2ea64a631 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -3351,8 +3351,11 @@ async function sendMessage(prompt, image, generationType, additionalNegativePref }, }; context.chat.push(message); + const messageId = context.chat.length - 1; + await eventSource.emit(event_types.MESSAGE_RECEIVED, messageId); context.addOneMessage(message); - context.saveChat(); + await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, messageId); + await context.saveChat(); } /** From 75bb59b204de890add296cfdc04b1033c77edf29 Mon Sep 17 00:00:00 2001 From: steve green Date: Tue, 6 Aug 2024 11:19:35 +0800 Subject: [PATCH 009/165] Update zh-cn.json --- public/locales/zh-cn.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 0519388e7..5b83fbe8c 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -707,10 +707,10 @@ "Restore User Input": "恢复用户输入", "Allow repositioning certain UI elements by dragging them. PC only, no effect on mobile": "允许通过拖动重新定位某些UI元素。仅适用于PC,对移动设备无影响", "Movable UI Panels": "可移动 UI 面板", + "Reset MovingUI panel sizes/locations.": "重置 MovingUI 面板大小/位置。", "MovingUI preset. Predefined/saved draggable positions": "可移动UI预设。预定义/保存的可拖动位置", "MUI Preset": "可移动 UI 预设", "Save movingUI changes to a new file": "将可移动UI更改保存到新文件中", - "Reset MovingUI panel sizes/locations.": "重置 MovingUI 面板大小/位置。", "Apply a custom CSS style to all of the ST GUI": "将自定义CSS样式应用于所有ST GUI", "Custom CSS": "自定义 CSS", "Expand the editor": "展开编辑器", @@ -730,6 +730,8 @@ "Press Send to continue": "按发送键以继续", "Show a button in the input area to ask the AI to continue (extend) its last message": "在输入区域中显示一个按钮,要求AI继续(延长)其上一条消息", "Quick 'Continue' button": "快速“继续”按钮", + "Show a button in the input area to ask the AI to impersonate your character for a single message": "在输入区域中显示一个按钮,让 AI 模仿你的角色发送一条消息。", + "Quick 'Impersonate' button": "快速“模仿”按钮", "Show arrow buttons on the last in-chat message to generate alternative AI responses. Both PC and mobile": "在聊天窗口的最后一条信息上显示箭头按钮,以生成AI的其他回复选项。适用于电脑和手机端。", "Swipes": "刷新回复按钮", "Allow using swiping gestures on the last in-chat message to trigger swipe generation. Mobile only, no effect on PC": "允许在最后一条聊天消息上使用滑动手势触发滑动生成。仅适用于移动设备,对PC无影响", @@ -1183,6 +1185,7 @@ "Pause script execution": "暂停执行脚本", "Abort script execution": "中止执行脚本", "Abort request": "中止请求", + "Ask AI to write your message for you": "让AI为您撰写消息", "Continue the last message": "继续上一条消息", "Send a message": "发送消息", "Close chat": "关闭聊天", @@ -1194,7 +1197,6 @@ "Manage chat files": "管理聊天文件", "Delete messages": "删除消息", "Regenerate": "重新生成", - "Ask AI to write your message for you": "请求AI为您撰写消息", "Impersonate": "AI 帮答", "Continue": "继续", "Bind user name to that avatar": "将用户名称绑定到该头像", @@ -1429,6 +1431,7 @@ "ext_regex_export_script": "导出脚本", "ext_regex_delete_script": "删除脚本", "Trigger Stable Diffusion": "触发Stable Diffusion", + "Abort current image generation task": "中止当前图像生成", "sd_Yourself": "你自己", "sd_Your_Face": "你的脸", "sd_Me": "我", @@ -1582,6 +1585,10 @@ "Only used when Main API is selected.": "仅在选择主 API 时使用。", "Old messages are vectorized gradually as you chat. To process all previous messages, click the button below.": "随着您聊天,旧消息会逐渐矢量化。\n要处理所有以前的消息,请单击下面的按钮。", "View Stats": "查看统计数据", + "Title/Memo": "标题/备忘录", + "Status": "状态", + "Position": "位置", + "Trigger %": "触发率 %", "Manager Users": "管理用户", "New User": "新用户", "Status:": "地位:", From 02c5a40b983f16aae88c0ef2757e4eace4f7021d Mon Sep 17 00:00:00 2001 From: steve02081504 Date: Tue, 6 Aug 2024 11:20:19 +0800 Subject: [PATCH 010/165] Crate WorldInfoKeywordHeaders.html --- .../templates/WorldInfoKeywordHeaders.html | 8 +++++++ public/scripts/world-info.js | 23 ++----------------- 2 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 public/scripts/templates/WorldInfoKeywordHeaders.html diff --git a/public/scripts/templates/WorldInfoKeywordHeaders.html b/public/scripts/templates/WorldInfoKeywordHeaders.html new file mode 100644 index 000000000..e6592ae1a --- /dev/null +++ b/public/scripts/templates/WorldInfoKeywordHeaders.html @@ -0,0 +1,8 @@ +
+ Title/Memo + Status + Position + Depth + Order + Trigger % +
diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index af5c917c0..344fab21e 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -17,6 +17,7 @@ import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCom import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; import { callGenericPopup, Popup, POPUP_TYPE } from './popup.js'; import { StructuredCloneMap } from './util/StructuredCloneMap.js'; +import { renderTemplateAsync } from './templates.js'; export const world_info_insertion_strategy = { evenly: 0, @@ -1854,27 +1855,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl worldEntriesList.find('*').off(); worldEntriesList.empty(); - const keywordHeaders = ` -
- - Title/Memo - - - Status - - - Position - - - Depth - - - Order - - - Trigger % - -
`; + const keywordHeaders = await renderTemplateAsync('WorldInfoKeywordHeaders'); const blocksPromises = page.map(async (entry) => await getWorldEntry(name, data, entry)).filter(x => x); const blocks = await Promise.all(blocksPromises); const isCustomOrder = $('#world_info_sort_order').find(':selected').data('rule') === 'custom'; From e45a445ef98922b83abba1e6c48108f1b8d77986 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:22:13 +0300 Subject: [PATCH 011/165] Init textgen model selects before loading settings --- public/script.js | 3 ++- public/scripts/textgen-models.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/script.js b/public/script.js index 22745982e..5c3c126dd 100644 --- a/public/script.js +++ b/public/script.js @@ -225,7 +225,7 @@ import { import { getBackgrounds, initBackgrounds, loadBackgroundSettings, background_settings } from './scripts/backgrounds.js'; import { hideLoader, showLoader } from './scripts/loader.js'; import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay.js'; -import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels } from './scripts/textgen-models.js'; +import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels } from './scripts/textgen-models.js'; import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId } from './scripts/chats.js'; import { initPresetManager } from './scripts/preset-manager.js'; import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js'; @@ -912,6 +912,7 @@ async function firstLoadInit() { await readSecretState(); initLocales(); initDefaultSlashCommands(); + initTextGenModels(); await getSystemMessages(); sendSystemMessage(system_message_types.WELCOME); await getSettings(); diff --git a/public/scripts/textgen-models.js b/public/scripts/textgen-models.js index 3ff4722ef..67a63f372 100644 --- a/public/scripts/textgen-models.js +++ b/public/scripts/textgen-models.js @@ -618,7 +618,7 @@ export function getCurrentDreamGenModelTokenizer() { } } -jQuery(function () { +export function initTextGenModels() { $('#mancer_model').on('change', onMancerModelSelect); $('#model_togetherai_select').on('change', onTogetherModelSelect); $('#model_infermaticai_select').on('change', onInfermaticAIModelSelect); @@ -718,4 +718,4 @@ jQuery(function () { $(this).trigger('change'); }); } -}); +} From 76e2586eaf9f9397f5da1a60d1bd723881f6a5ed Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:27:38 +0300 Subject: [PATCH 012/165] Don't close providers dropdowns on select --- public/scripts/textgen-models.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/scripts/textgen-models.js b/public/scripts/textgen-models.js index 67a63f372..aa663c2a4 100644 --- a/public/scripts/textgen-models.js +++ b/public/scripts/textgen-models.js @@ -708,6 +708,7 @@ export function initTextGenModels() { searchInputPlaceholder: 'Search providers...', searchInputCssClass: 'text_pole', width: '100%', + closeOnSelect: false, }); providersSelect.on('select2:select', function (/** @type {any} */ evt) { const element = evt.params.data.element; From c76306d461fd7a45625a262721fe7622922c407b Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:33:56 +0300 Subject: [PATCH 013/165] Restore CC OpenRouter providers on load --- public/scripts/openai.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index bc211ccbc..ea5c685da 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -3048,6 +3048,7 @@ function loadOpenAISettings(data, settings) { oai_settings.names_behavior = settings.names_behavior ?? default_settings.names_behavior; oai_settings.continue_postfix = settings.continue_postfix ?? default_settings.continue_postfix; oai_settings.function_calling = settings.function_calling ?? default_settings.function_calling; + oai_settings.openrouter_providers = settings.openrouter_providers ?? default_settings.openrouter_providers; // Migrate from old settings if (settings.names_in_completion === true) { From ed3f028a36707162c3cc8729b411f95fa28deb4e Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 6 Aug 2024 11:30:17 +0200 Subject: [PATCH 014/165] consistent template names --- public/scripts/world-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 344fab21e..dba73c106 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -1855,7 +1855,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl worldEntriesList.find('*').off(); worldEntriesList.empty(); - const keywordHeaders = await renderTemplateAsync('WorldInfoKeywordHeaders'); + const keywordHeaders = await renderTemplateAsync('worldInfoKeywordHeaders'); const blocksPromises = page.map(async (entry) => await getWorldEntry(name, data, entry)).filter(x => x); const blocks = await Promise.all(blocksPromises); const isCustomOrder = $('#world_info_sort_order').find(':selected').data('rule') === 'custom'; From d6e7fd78adfcecdb0bca84471702b5d978f9d2b9 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:28:37 +0300 Subject: [PATCH 015/165] Add event handlers for dynamically added neo-range-inputs --- public/script.js | 88 +++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/public/script.js b/public/script.js index 5c3c126dd..fe353fd80 100644 --- a/public/script.js +++ b/public/script.js @@ -10745,62 +10745,66 @@ jQuery(async function () { var isManualInput = false; var valueBeforeManualInput; - $('.range-block-counter input, .neo-range-input').on('click', function () { + $(document).on('input', '.range-block-counter input, .neo-range-input', function () { valueBeforeManualInput = $(this).val(); console.log(valueBeforeManualInput); - }) - .on('change', function (e) { - e.target.focus(); - e.target.dispatchEvent(new Event('keyup')); - }) - .on('keydown', function (e) { - const masterSelector = '#' + $(this).data('for'); - const masterElement = $(masterSelector); - if (e.key === 'Enter') { - let manualInput = Number($(this).val()); - if (isManualInput) { - //disallow manual inputs outside acceptable range - if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) { - //if value is ok, assign to slider and update handle text and position - //newSlider.val(manualInput) - //handleSlideEvent.call(newSlider, null, { value: parseFloat(manualInput) }, 'manual'); - valueBeforeManualInput = manualInput; - $(masterElement).val($(this).val()).trigger('input', { forced: true }); - } else { - //if value not ok, warn and reset to last known valid value - toastr.warning(`Invalid value. Must be between ${$(this).attr('min')} and ${$(this).attr('max')}`); - console.log(valueBeforeManualInput); - //newSlider.val(valueBeforeManualInput) - $(this).val(valueBeforeManualInput); - } - } - } - }) - .on('keyup', function () { - valueBeforeManualInput = $(this).val(); - console.log(valueBeforeManualInput); - isManualInput = true; - }) - //trigger slider changes when user clicks away - .on('mouseup blur', function () { - const masterSelector = '#' + $(this).data('for'); - const masterElement = $(masterSelector); + }); + + $(document).on('change', '.range-block-counter input, .neo-range-input', function (e) { + e.target.focus(); + e.target.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true })); + }); + + $(document).on('keydown', '.range-block-counter input, .neo-range-input', function (e) { + const masterSelector = '#' + $(this).data('for'); + const masterElement = $(masterSelector); + if (e.key === 'Enter') { let manualInput = Number($(this).val()); if (isManualInput) { - //if value is between correct range for the slider + //disallow manual inputs outside acceptable range if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) { + //if value is ok, assign to slider and update handle text and position + //newSlider.val(manualInput) + //handleSlideEvent.call(newSlider, null, { value: parseFloat(manualInput) }, 'manual'); valueBeforeManualInput = manualInput; - //set the slider value to input value $(masterElement).val($(this).val()).trigger('input', { forced: true }); } else { //if value not ok, warn and reset to last known valid value toastr.warning(`Invalid value. Must be between ${$(this).attr('min')} and ${$(this).attr('max')}`); console.log(valueBeforeManualInput); + //newSlider.val(valueBeforeManualInput) $(this).val(valueBeforeManualInput); } } - isManualInput = false; - }); + } + }); + + $(document).on('keyup', '.range-block-counter input, .neo-range-input', function () { + valueBeforeManualInput = $(this).val(); + console.log(valueBeforeManualInput); + isManualInput = true; + }); + + //trigger slider changes when user clicks away + $(document).on('mouseup blur', '.range-block-counter input, .neo-range-input', function () { + const masterSelector = '#' + $(this).data('for'); + const masterElement = $(masterSelector); + let manualInput = Number($(this).val()); + if (isManualInput) { + //if value is between correct range for the slider + if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) { + valueBeforeManualInput = manualInput; + //set the slider value to input value + $(masterElement).val($(this).val()).trigger('input', { forced: true }); + } else { + //if value not ok, warn and reset to last known valid value + toastr.warning(`Invalid value. Must be between ${$(this).attr('min')} and ${$(this).attr('max')}`); + console.log(valueBeforeManualInput); + $(this).val(valueBeforeManualInput); + } + } + isManualInput = false; + }); $('.user_stats_button').on('click', function () { userStatsHandler(); From f3734ae285d60befbdc2870f16a60421abf8112e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:45:05 +0300 Subject: [PATCH 016/165] Remove token limit from multimodal caption request --- src/endpoints/openai.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/endpoints/openai.js b/src/endpoints/openai.js index 662974088..4f8afc557 100644 --- a/src/endpoints/openai.js +++ b/src/endpoints/openai.js @@ -67,7 +67,6 @@ router.post('/caption-image', jsonParser, async (request, response) => { ], }, ], - max_tokens: 500, ...bodyParams, }; From 32c48cf9fab2b12203f8b97ee36581a3ab003036 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:58:19 +0300 Subject: [PATCH 017/165] Fix default value for OpenRouter Top A --- default/content/presets/openai/Default.json | 2 +- public/scripts/openai.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/default/content/presets/openai/Default.json b/default/content/presets/openai/Default.json index e32590a32..e2345c687 100644 --- a/default/content/presets/openai/Default.json +++ b/default/content/presets/openai/Default.json @@ -22,7 +22,7 @@ "count_penalty": 0, "top_p": 1, "top_k": 0, - "top_a": 1, + "top_a": 0, "min_p": 0, "repetition_penalty": 1, "openai_max_context": 4095, diff --git a/public/scripts/openai.js b/public/scripts/openai.js index ea5c685da..b8c0efd8d 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -238,7 +238,7 @@ const default_settings = { top_p_openai: 1.0, top_k_openai: 0, min_p_openai: 0, - top_a_openai: 1, + top_a_openai: 0, repetition_penalty_openai: 1, stream_openai: false, websearch_cohere: false, @@ -318,7 +318,7 @@ const oai_settings = { top_p_openai: 1.0, top_k_openai: 0, min_p_openai: 0, - top_a_openai: 1, + top_a_openai: 0, repetition_penalty_openai: 1, stream_openai: false, websearch_cohere: false, From f0b13d317229cb653c24ed413ab7e86aa864706b Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:58:36 +0300 Subject: [PATCH 018/165] Allow wand SD gens when LLM not connected --- public/scripts/extensions/stable-diffusion/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index 2ea64a631..73f1412dc 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -3399,7 +3399,7 @@ async function addSDGenButtons() { $(document).on('click touchend', function (e) { const target = $(e.target); if (target.is(dropdown) || target.closest(dropdown).length) return; - if ((target.is(button) || target.closest(button).length) && !dropdown.is(':visible') && $('#send_but').is(':visible')) { + if ((target.is(button) || target.closest(button).length) && !dropdown.is(':visible')) { e.preventDefault(); dropdown.fadeIn(animation_duration); From 93c7dd50f5d1860b92e72a3216064007b1c23ab3 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:01:43 +0300 Subject: [PATCH 019/165] Fix template name case --- public/scripts/templates/WorldInfoKeywordHeaders.html | 8 -------- public/scripts/templates/worldInfoKeywordHeaders.html | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 public/scripts/templates/WorldInfoKeywordHeaders.html create mode 100644 public/scripts/templates/worldInfoKeywordHeaders.html diff --git a/public/scripts/templates/WorldInfoKeywordHeaders.html b/public/scripts/templates/WorldInfoKeywordHeaders.html deleted file mode 100644 index e6592ae1a..000000000 --- a/public/scripts/templates/WorldInfoKeywordHeaders.html +++ /dev/null @@ -1,8 +0,0 @@ -
- Title/Memo - Status - Position - Depth - Order - Trigger % -
diff --git a/public/scripts/templates/worldInfoKeywordHeaders.html b/public/scripts/templates/worldInfoKeywordHeaders.html new file mode 100644 index 000000000..5bc996802 --- /dev/null +++ b/public/scripts/templates/worldInfoKeywordHeaders.html @@ -0,0 +1,8 @@ +
+ Title/Memo + Status + Position + Depth + Order + Trigger % +
From 3fab783e440641c757fee390e83afa1728d10f5b Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Wed, 7 Aug 2024 21:35:15 +0200 Subject: [PATCH 020/165] Add GPT-4o checkpoint model - This one supports "Structured Outputs" --- public/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 63d5a98ac..3cdf22ad0 100644 --- a/public/index.html +++ b/public/index.html @@ -2570,6 +2570,7 @@ + @@ -6558,4 +6559,4 @@ - \ No newline at end of file + From 6e1ba5f7e24648c0eff7a22b09a34f618745caff Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 8 Aug 2024 00:21:18 +0300 Subject: [PATCH 021/165] Change event handler type for custom CSS Closes #2624 --- public/scripts/power-user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 337fceb75..c50cf7ae3 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -3310,8 +3310,8 @@ $(document).ready(() => { saveSettingsDebounced(); }); - $('#customCSS').on('change', () => { - power_user.custom_css = $('#customCSS').val(); + $('#customCSS').on('input', () => { + power_user.custom_css = String($('#customCSS').val()); localStorage.setItem(storage_keys.custom_css, power_user.custom_css); saveSettingsDebounced(); applyCustomCSS(); From b9857eb315553616b66aa5215eaa267f37704994 Mon Sep 17 00:00:00 2001 From: Edward Kim Date: Thu, 8 Aug 2024 00:08:03 -0400 Subject: [PATCH 022/165] Added block entropy endpoints for chat and image --- public/index.html | 15 +++ public/scripts/RossAscends-mods.js | 1 + .../extensions/stable-diffusion/index.js | 65 ++++++++++++- .../extensions/stable-diffusion/settings.html | 3 +- public/scripts/openai.js | 54 +++++++++++ public/scripts/secrets.js | 2 + public/scripts/slash-commands.js | 1 + public/scripts/tokenizers.js | 9 ++ src/constants.js | 1 + src/endpoints/backends/chat-completions.js | 10 ++ src/endpoints/secrets.js | 1 + src/endpoints/stable-diffusion.js | 93 +++++++++++++++++++ 12 files changed, 253 insertions(+), 2 deletions(-) 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 @@
-
+