From bf66a3957907e50064e7ab23988ba8000b50fdb8 Mon Sep 17 00:00:00 2001 From: DocShotgun <126566557+DocShotgun@users.noreply.github.com> Date: Tue, 6 May 2025 00:32:29 -0700 Subject: [PATCH 001/162] Update llama.cpp textgen settings * Add min_keep, a llama.cpp-exclusive setting for constraining the effect of truncation samplers * Enable nsigma for llama.cpp, and add llama.cpp alias top_n_sigma, add nsigma to the llama.cpp sampler order block * Allow a negative value of nsigma as this represents 'disabled' in llama.cpp (while 0 is deterministic) * Remove tfs and top_a as these are not supported by llama.cpp (tfs was removed, and top_a was never supported) * Correct the identification string for typical_p in the llama.cpp sampler order block * Add penalties to the llama.cpp sampler order block --- public/index.html | 23 ++++++++++++++++------- public/scripts/textgen-settings.js | 12 +++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index 954a0a57d..5fae60354 100644 --- a/public/index.html +++ b/public/index.html @@ -1284,7 +1284,7 @@ -
+
Top A
@@ -1292,7 +1292,7 @@
-
+
TFS
@@ -1308,13 +1308,21 @@
-
+
Top nsigma
- - + + +
+
+ + Min Keep +
+
+ +
@@ -1769,11 +1777,12 @@
Temperature
Top K
Top P
-
Typical P
-
Tail Free Sampling
+
Typical P
Min P
Exclude Top Choices
DRY
+
Rep/Freq/Pres Penalties
+
Top N-Sigma
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index cbdfc0a5a..c1813f2e7 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -806,7 +806,7 @@ jQuery(function () { 'dry_penalty_last_n_textgenerationwebui': 0, 'xtc_threshold_textgenerationwebui': 0.1, 'xtc_probability_textgenerationwebui': 0, - 'nsigma_textgenerationwebui': [LLAMACPP].includes(settings.type) ? -0.01 : 0, + 'nsigma_textgenerationwebui': 0, 'min_keep_textgenerationwebui': 0, }; @@ -1335,8 +1335,8 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, 'xtc_threshold': settings.xtc_threshold, 'xtc_probability': settings.xtc_probability, - 'nsigma': settings.nsigma, - 'top_n_sigma': settings.nsigma, + 'nsigma': [LLAMACPP].includes(settings.type) && settings.nsigma === 0 ? -1 : settings.nsigma, + 'top_n_sigma': [LLAMACPP].includes(settings.type) && settings.nsigma === 0 ? -1 : settings.nsigma, 'min_keep': settings.min_keep, }; const nonAphroditeParams = { From 5e31a21d8d8ff964370272b0896ee569f9a1a93e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 6 May 2025 22:02:20 +0300 Subject: [PATCH 005/162] Decouple "click to edit" from document mode --- public/index.html | 7 ++++--- public/scripts/chats.js | 3 ++- public/scripts/power-user.js | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/public/index.html b/public/index.html index c7b0e1ad5..3c658125c 100644 --- a/public/index.html +++ b/public/index.html @@ -4498,10 +4498,11 @@ Tags as Folders - +
- -
diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 3c5795709..51b272b50 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -1576,7 +1576,8 @@ jQuery(function () { await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true }); }); - $(document).on('click', 'body.documentstyle .mes .mes_text', function () { + $(document).on('click', 'body .mes .mes_text', function () { + if (!power_user.click_to_edit) return; if (window.getSelection().toString()) return; if ($('.edit_textarea').length) return; $(this).closest('.mes').find('.mes_edit').trigger('click'); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index a4baaa901..00a3f1d4b 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -320,6 +320,7 @@ let power_user = { external_media_allowed_overrides: [], external_media_forbidden_overrides: [], pin_styles: true, + click_to_edit: false, }; let themes = []; @@ -1322,6 +1323,12 @@ function applyTheme(name) { switchSwipeNumAllMessages(); }, }, + { + key: 'click_to_edit', + action: () => { + $('#click_to_edit').prop('checked', power_user.click_to_edit); + }, + }, ]; for (const { key, selector, type, action } of themeProperties) { @@ -1647,6 +1654,7 @@ async function loadPowerUserSettings(settings, data) { $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat); $('#forbid_external_media').prop('checked', power_user.forbid_external_media); $('#pin_styles').prop('checked', power_user.pin_styles); + $('#click_to_edit').prop('checked', power_user.click_to_edit); for (const theme of themes) { const option = document.createElement('option'); @@ -2379,6 +2387,7 @@ function getThemeObject(name) { reduced_motion: power_user.reduced_motion, compact_input_area: power_user.compact_input_area, show_swipe_num_all_messages: power_user.show_swipe_num_all_messages, + click_to_edit: power_user.click_to_edit, }; } @@ -3929,6 +3938,11 @@ $(document).ready(() => { applyStylePins(); }); + $('#click_to_edit').on('input', function () { + power_user.click_to_edit = !!$(this).prop('checked'); + saveSettingsDebounced(); + }); + $('#ui_preset_import_button').on('click', function () { $('#ui_preset_import_file').trigger('click'); }); From 3be991591fa4d07e1546b9bbc34c00753aa0a40a Mon Sep 17 00:00:00 2001 From: DocShotgun <126566557+DocShotgun@users.noreply.github.com> Date: Tue, 6 May 2025 14:11:00 -0700 Subject: [PATCH 006/162] Remove special handling of nsigma for llama.cpp * 0 now changed to disable/no-op upstream --- public/scripts/textgen-settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index c1813f2e7..69f6372fb 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1335,8 +1335,8 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, 'xtc_threshold': settings.xtc_threshold, 'xtc_probability': settings.xtc_probability, - 'nsigma': [LLAMACPP].includes(settings.type) && settings.nsigma === 0 ? -1 : settings.nsigma, - 'top_n_sigma': [LLAMACPP].includes(settings.type) && settings.nsigma === 0 ? -1 : settings.nsigma, + 'nsigma': settings.nsigma, + 'top_n_sigma': settings.nsigma, 'min_keep': settings.min_keep, }; const nonAphroditeParams = { From 7a4d6ecfde0d500aaa301190e0dabf2ac87919f0 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 7 May 2025 11:12:41 +0000 Subject: [PATCH 007/162] Migrate old preference for "click to edit" setting based on chat display style --- public/scripts/power-user.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 00a3f1d4b..98e811363 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -1459,6 +1459,10 @@ async function loadPowerUserSettings(settings, data) { const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript)); // Load from settings.json if (settings.power_user !== undefined) { + // Migrate old preference to a new setting + if (settings.power_user.click_to_edit === undefined && settings.power_user.chat_display === chat_styles.DOCUMENT) { + settings.power_user.click_to_edit = true; + } Object.assign(power_user, settings.power_user); } From fa8ea7c60d893c660f2b2f1b341ccad2d346f5b8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 7 May 2025 20:09:56 +0300 Subject: [PATCH 008/162] mistral-medium-2505 --- public/index.html | 1 + public/scripts/extensions/caption/settings.html | 2 ++ public/scripts/openai.js | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 13567e2aa..962c6f121 100644 --- a/public/index.html +++ b/public/index.html @@ -3246,6 +3246,7 @@ + diff --git a/public/scripts/extensions/caption/settings.html b/public/scripts/extensions/caption/settings.html index 67e179b43..d345096e7 100644 --- a/public/scripts/extensions/caption/settings.html +++ b/public/scripts/extensions/caption/settings.html @@ -46,6 +46,8 @@ + + diff --git a/public/scripts/openai.js b/public/scripts/openai.js index b37560fbb..b00f4de8b 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -4289,9 +4289,10 @@ function getMistralMaxContext(model, isUnlocked) { 'codestral-2405': 32768, 'mistral-embed': 32768, 'mistral-large-2402': 32768, - 'mistral-medium': 32768, + 'mistral-medium': 131072, 'mistral-medium-2312': 32768, - 'mistral-medium-latest': 32768, + 'mistral-medium-2505': 131072, + 'mistral-medium-latest': 131072, 'mistral-moderation-2411': 32768, 'mistral-moderation-latest': 32768, 'mistral-ocr-2503': 32768, @@ -5153,6 +5154,8 @@ export function isImageInliningSupported() { // MistralAI 'mistral-small-2503', 'mistral-small-latest', + 'mistral-medium-latest', + 'mistral-medium-2505', 'pixtral', // xAI (Grok) 'grok-2-vision', From da7f97b66377a970f1accb890ffd865aeb269ffb Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 8 May 2025 20:28:35 +0300 Subject: [PATCH 009/162] Claude: "Auto" effort = no thinking --- src/endpoints/backends/chat-completions.js | 7 ++++--- src/prompt-converters.js | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index e440d6c01..b6cce98a0 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -200,11 +200,12 @@ async function sendClaudeRequest(request, response) { betaHeaders.push('prompt-caching-2024-07-31'); } - if (useThinking) { + const reasoningEffort = request.body.reasoning_effort; + const budgetTokens = calculateClaudeBudgetTokens(requestBody.max_tokens, reasoningEffort, requestBody.stream); + + if (useThinking && Number.isInteger(budgetTokens)) { // No prefill when thinking voidPrefill = true; - const reasoningEffort = request.body.reasoning_effort; - const budgetTokens = calculateClaudeBudgetTokens(requestBody.max_tokens, reasoningEffort, requestBody.stream); const minThinkTokens = 1024; if (requestBody.max_tokens <= minThinkTokens) { const newValue = requestBody.max_tokens + minThinkTokens; diff --git a/src/prompt-converters.js b/src/prompt-converters.js index c894a4736..ae4c0c0fb 100644 --- a/src/prompt-converters.js +++ b/src/prompt-converters.js @@ -917,19 +917,20 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth) { * @param {number} maxTokens Maximum tokens * @param {string} reasoningEffort Reasoning effort * @param {boolean} stream If streaming is enabled - * @returns {number} Budget tokens + * @returns {number?} Budget tokens */ export function calculateClaudeBudgetTokens(maxTokens, reasoningEffort, stream) { let budgetTokens = 0; switch (reasoningEffort) { + case REASONING_EFFORT.auto: + return null; case REASONING_EFFORT.min: budgetTokens = 1024; break; case REASONING_EFFORT.low: budgetTokens = Math.floor(maxTokens * 0.1); break; - case REASONING_EFFORT.auto: case REASONING_EFFORT.medium: budgetTokens = Math.floor(maxTokens * 0.25); break; From c1c77a6a60b30cbe85bed3b4d8a3e8c67c2fa4ac Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 8 May 2025 20:51:38 +0300 Subject: [PATCH 010/162] Claude: add web search tool, adjust prefill voiding Closes #3968 --- public/index.html | 2 +- src/endpoints/backends/chat-completions.js | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index ae9631e55..942764ef7 100644 --- a/public/index.html +++ b/public/index.html @@ -1963,7 +1963,7 @@
-
+
+
+ Source: +   + +
diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 94d642afa..2a705e8b2 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -196,6 +196,17 @@ export class PromptCollection { } class PromptManager { + get promptSources() { + return { + charDescription: t`Character Description`, + charPersonality: t`Character Personality`, + scenario: t`Character Scenario`, + personaDescription: t`Persona Description`, + worldInfoBefore: t`World Info (↑Char)`, + worldInfoAfter: t`World Info (↓Char)`, + }; + } + constructor() { this.systemPrompts = [ 'main', @@ -408,6 +419,7 @@ class PromptManager { this.handleResetPrompt = (event) => { const promptId = event.target.dataset.pmPrompt; const prompt = this.getPromptById(promptId); + const isPulledPrompt = Object.keys(this.promptSources).includes(promptId); switch (promptId) { case 'main': @@ -439,6 +451,12 @@ class PromptManager { document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_forbid_overrides').checked = prompt.forbid_overrides ?? false; document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block').style.visibility = this.overridablePrompts.includes(prompt.identifier) ? 'visible' : 'hidden'; document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_prompt').disabled = prompt.marker ?? false; + document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source_block').style.display = isPulledPrompt ? '' : 'none'; + + if (isPulledPrompt) { + const sourceName = this.promptSources[promptId]; + document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source').textContent = sourceName; + } if (!this.systemPrompts.includes(promptId)) { document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_injection_position').removeAttribute('disabled'); @@ -1207,6 +1225,9 @@ class PromptManager { const injectionDepthBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_depth_block'); const forbidOverridesField = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_forbid_overrides'); const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block'); + const entrySourceBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source_block'); + const entrySource = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source'); + const isPulledPrompt = Object.keys(this.promptSources).includes(prompt.identifier); nameField.value = prompt.name ?? ''; roleField.value = prompt.role || 'system'; @@ -1218,6 +1239,12 @@ class PromptManager { injectionPositionField.removeAttribute('disabled'); forbidOverridesField.checked = prompt.forbid_overrides ?? false; forbidOverridesBlock.style.visibility = this.overridablePrompts.includes(prompt.identifier) ? 'visible' : 'hidden'; + entrySourceBlock.style.display = isPulledPrompt ? '' : 'none'; + + if (isPulledPrompt) { + const sourceName = this.promptSources[prompt.identifier]; + entrySource.textContent = sourceName; + } if (this.systemPrompts.includes(prompt.identifier)) { injectionPositionField.setAttribute('disabled', 'disabled'); @@ -1303,6 +1330,8 @@ class PromptManager { const injectionDepthBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_depth_block'); const forbidOverridesField = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_forbid_overrides'); const forbidOverridesBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_forbid_overrides_block'); + const entrySourceBlock = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source_block'); + const entrySource = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_source'); nameField.value = ''; roleField.selectedIndex = 0; @@ -1314,6 +1343,8 @@ class PromptManager { injectionDepthBlock.style.visibility = 'unset'; forbidOverridesBlock.style.visibility = 'unset'; forbidOverridesField.checked = false; + entrySourceBlock.style.display = 'none'; + entrySource.textContent = ''; roleField.disabled = false; } From e6530cb22dc360b38d0b67c3250bad1758cb8fd6 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 10 May 2025 18:19:22 +0300 Subject: [PATCH 018/162] Install jimp plugins explicitly --- package-lock.json | 2 ++ package.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/package-lock.json b/package-lock.json index 159558e74..f02e73a89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@jimp/js-bmp": "^1.6.0", "@jimp/js-gif": "^1.6.0", "@jimp/js-tiff": "^1.6.0", + "@jimp/plugin-blit": "^1.6.0", "@jimp/plugin-circle": "^1.6.0", "@jimp/plugin-color": "^1.6.0", "@jimp/plugin-contain": "^1.6.0", @@ -28,6 +29,7 @@ "@jimp/plugin-flip": "^1.6.0", "@jimp/plugin-mask": "^1.6.0", "@jimp/plugin-quantize": "^1.6.0", + "@jimp/plugin-resize": "^1.6.0", "@jimp/plugin-rotate": "^1.6.0", "@jimp/plugin-threshold": "^1.6.0", "@jimp/wasm-avif": "^1.6.0", diff --git a/package.json b/package.json index 0733f177d..9744c2f4a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@jimp/js-bmp": "^1.6.0", "@jimp/js-gif": "^1.6.0", "@jimp/js-tiff": "^1.6.0", + "@jimp/plugin-blit": "^1.6.0", "@jimp/plugin-circle": "^1.6.0", "@jimp/plugin-color": "^1.6.0", "@jimp/plugin-contain": "^1.6.0", @@ -18,6 +19,7 @@ "@jimp/plugin-flip": "^1.6.0", "@jimp/plugin-mask": "^1.6.0", "@jimp/plugin-quantize": "^1.6.0", + "@jimp/plugin-resize": "^1.6.0", "@jimp/plugin-rotate": "^1.6.0", "@jimp/plugin-threshold": "^1.6.0", "@jimp/wasm-avif": "^1.6.0", From 2aa5addb1d351101565976f0f10538dcdcfed299 Mon Sep 17 00:00:00 2001 From: 50h100a Date: Sat, 10 May 2025 19:04:32 -0400 Subject: [PATCH 019/162] Mancer parameters: - Add XTC - Add DRY - Remove Mirostat --- public/index.html | 6 +++--- public/scripts/textgen-settings.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 08b1bdb09..d1ddc9423 100644 --- a/public/index.html +++ b/public/index.html @@ -1406,7 +1406,7 @@ -
+

@@ -1427,7 +1427,7 @@

- -
+

diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 69f6372fb..210d60070 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1439,6 +1439,17 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso params.dynatemp_max = params.dynatemp_high; delete params.dynatemp_low; delete params.dynatemp_high; + const sequenceBreakers = (() => { + try { + return JSON.parse(params.dry_sequence_breakers); + } catch { + if (typeof params.dry_sequence_breakers === 'string') { + return params.dry_sequence_breakers.split(','); + } + return undefined; + } + })(); + params.dry_sequence_breakers = sequenceBreakers; } if (settings.type === TABBY) { From fc1020a8e4d640823a460ff1d9403e0f54fe7494 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 11 May 2025 11:07:13 +0300 Subject: [PATCH 020/162] Refactor sequence breaker parsing in getTextGenGenerationData function --- public/scripts/textgen-settings.js | 34 +++++++++++------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 210d60070..b8c3df044 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1338,6 +1338,16 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso 'nsigma': settings.nsigma, 'top_n_sigma': settings.nsigma, 'min_keep': settings.min_keep, + parseSequenceBreakers: function () { + try { + return JSON.parse(this.dry_sequence_breakers); + } catch { + if (typeof this.dry_sequence_breakers === 'string') { + return this.dry_sequence_breakers.split(','); + } + return undefined; + } + }, }; const nonAphroditeParams = { 'rep_pen': settings.rep_pen, @@ -1439,17 +1449,7 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso params.dynatemp_max = params.dynatemp_high; delete params.dynatemp_low; delete params.dynatemp_high; - const sequenceBreakers = (() => { - try { - return JSON.parse(params.dry_sequence_breakers); - } catch { - if (typeof params.dry_sequence_breakers === 'string') { - return params.dry_sequence_breakers.split(','); - } - return undefined; - } - })(); - params.dry_sequence_breakers = sequenceBreakers; + params.dry_sequence_breakers = params.parseSequenceBreakers(); } if (settings.type === TABBY) { @@ -1485,17 +1485,7 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso : []; const tokenBans = toIntArray(banned_tokens); logitBiasArray.push(...tokenBans.map(x => [Number(x), false])); - const sequenceBreakers = (() => { - try { - return JSON.parse(params.dry_sequence_breakers); - } catch { - if (typeof params.dry_sequence_breakers === 'string') { - return params.dry_sequence_breakers.split(','); - } - - return undefined; - } - })(); + const sequenceBreakers = params.parseSequenceBreakers(); const llamaCppParams = { 'logit_bias': logitBiasArray, // Conflicts with ooba's grammar_string From 09f2b2f731f79a1df6a8382db2a2b447bbc9e433 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 11 May 2025 11:09:15 +0300 Subject: [PATCH 021/162] Handle unknown chat completion sources gracefully by logging an error and returning an empty string --- public/scripts/openai.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index c7ad1a639..be77acdca 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1661,7 +1661,8 @@ export function getChatCompletionModel(source = null) { case chat_completion_sources.XAI: return oai_settings.xai_model; default: - throw new Error(`Unknown chat completion source: ${activeSource}`); + console.error(`Unknown chat completion source: ${activeSource}`); + return ''; } } From 99e3c22311fbc660482162c8c0803d459dfdf673 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 11 May 2025 12:28:33 +0300 Subject: [PATCH 022/162] Refactor firstLoadInit to include initCustomSelectedSamplers and addDebugFunctions --- public/script.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index 77eaaaa99..2cfa936db 100644 --- a/public/script.js +++ b/public/script.js @@ -1010,6 +1010,8 @@ async function firstLoadInit() { initBulkEdit(); initReasoning(); await initScrapers(); + initCustomSelectedSamplers(); + addDebugFunctions(); doDailyExtensionUpdatesCheck(); await hideLoader(); await fixViewport(); @@ -12274,8 +12276,6 @@ jQuery(async function () { // Added here to prevent execution before script.js is loaded and get rid of quirky timeouts await firstLoadInit(); - addDebugFunctions(); - eventSource.on(event_types.CHAT_DELETED, async (name) => { await deleteItemizedPrompts(name); }); @@ -12283,8 +12283,6 @@ jQuery(async function () { await deleteItemizedPrompts(name); }); - initCustomSelectedSamplers(); - window.addEventListener('beforeunload', (e) => { if (isChatSaving) { e.preventDefault(); From 420d568cd3ee6095bd4235e6f2c78789b38fb791 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 11 May 2025 20:14:11 +0300 Subject: [PATCH 023/162] Pollinations - Text (#3985) * [wip] Pollinations for text * Implement generate API request * Determine Pollinations model tools via models list * Add Pollinations option to /model command * Add Pollinations support to caption * Update link to pollinations site * Fix type errors in openai.js * Fix API connection test to use AbortController for request cancellation * Remove hard coded list of pollinations vision models * Remove openai-audio from captioning models --- public/img/pollinations.svg | 1 + public/index.html | 26 +++- public/script.js | 2 +- public/scripts/PromptManager.js | 16 +-- public/scripts/RossAscends-mods.js | 1 + public/scripts/extensions/caption/index.js | 2 +- .../scripts/extensions/caption/settings.html | 13 ++ public/scripts/openai.js | 126 +++++++++++++----- public/scripts/slash-commands.js | 1 + public/scripts/tool-calling.js | 10 +- src/constants.js | 1 + src/endpoints/backends/chat-completions.js | 20 ++- src/endpoints/openai.js | 6 +- 13 files changed, 174 insertions(+), 51 deletions(-) create mode 100644 public/img/pollinations.svg diff --git a/public/img/pollinations.svg b/public/img/pollinations.svg new file mode 100644 index 000000000..dad71c9d3 --- /dev/null +++ b/public/img/pollinations.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/index.html b/public/index.html index d1ddc9423..1d3f8d75c 100644 --- a/public/index.html +++ b/public/index.html @@ -974,7 +974,7 @@

-
+
Seed
@@ -1977,7 +1977,7 @@
-
+
-
+
-
+
-
+
+
+

Pollinations Model

+ +
+ + Provided free of charge by Pollinations.AI + +
+ + Avoid sending sensitive information. Provider's outputs may include ads. + +
+

Prompt Post-Processing

@@ -151,6 +152,18 @@ + + + + + + + + + + + +
diff --git a/public/scripts/openai.js b/public/scripts/openai.js index be77acdca..850100eb9 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -185,6 +185,7 @@ export const chat_completion_sources = { NANOGPT: 'nanogpt', DEEPSEEK: 'deepseek', XAI: 'xai', + POLLINATIONS: 'pollinations', }; const character_names_behavior = { @@ -268,6 +269,7 @@ export const settingsToUpdate = { deepseek_model: ['#model_deepseek_select', 'deepseek_model', false], zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false], xai_model: ['#model_xai_select', 'xai_model', false], + pollinations_model: ['#model_pollinations_select', 'pollinations_model', false], custom_model: ['#custom_model_id', 'custom_model', false], custom_url: ['#custom_api_url_text', 'custom_url', false], custom_include_body: ['#custom_include_body', 'custom_include_body', false], @@ -357,6 +359,7 @@ const default_settings = { zerooneai_model: 'yi-large', deepseek_model: 'deepseek-chat', xai_model: 'grok-3-beta', + pollinations_model: 'openai', custom_model: '', custom_url: '', custom_include_body: '', @@ -438,6 +441,7 @@ const oai_settings = { zerooneai_model: 'yi-large', deepseek_model: 'deepseek-chat', xai_model: 'grok-3-beta', + pollinations_model: 'openai', custom_model: '', custom_url: '', custom_include_body: '', @@ -1181,7 +1185,7 @@ async function populateChatCompletion(prompts, chatCompletion, { bias, quietProm * Combines system prompts with prompt manager prompts * * @param {Object} options - An object with optional settings. - * @param {string} options.Scenario - The scenario or context of the dialogue. + * @param {string} options.scenario - The scenario or context of the dialogue. * @param {string} options.charPersonality - Description of the character's personality. * @param {string} options.name2 - The second name to be used in the messages. * @param {string} options.worldInfoBefore - The world info to be added before the main conversation. @@ -1195,8 +1199,8 @@ async function populateChatCompletion(prompts, chatCompletion, { bias, quietProm * @param {string} options.personaDescription * @returns {Promise} prompts - The prepared and merged system and user-defined prompts. */ -async function preparePromptsForChatCompletion({ Scenario, charPersonality, name2, worldInfoBefore, worldInfoAfter, charDescription, quietPrompt, bias, extensionPrompts, systemPromptOverride, jailbreakPromptOverride, personaDescription }) { - const scenarioText = Scenario && oai_settings.scenario_format ? substituteParams(oai_settings.scenario_format) : ''; +async function preparePromptsForChatCompletion({ scenario, charPersonality, name2, worldInfoBefore, worldInfoAfter, charDescription, quietPrompt, bias, extensionPrompts, systemPromptOverride, jailbreakPromptOverride, personaDescription }) { + const scenarioText = scenario && oai_settings.scenario_format ? substituteParams(oai_settings.scenario_format) : ''; const charPersonalityText = charPersonality && oai_settings.personality_format ? substituteParams(oai_settings.personality_format) : ''; const groupNudge = substituteParams(oai_settings.group_nudge_prompt); const impersonationPrompt = oai_settings.impersonation_prompt ? substituteParams(oai_settings.impersonation_prompt) : ''; @@ -1352,7 +1356,7 @@ async function preparePromptsForChatCompletion({ Scenario, charPersonality, name * @param {string} content.name2 - The second name to be used in the messages. * @param {string} content.charDescription - Description of the character. * @param {string} content.charPersonality - Description of the character's personality. - * @param {string} content.Scenario - The scenario or context of the dialogue. + * @param {string} content.scenario - The scenario or context of the dialogue. * @param {string} content.worldInfoBefore - The world info to be added before the main conversation. * @param {string} content.worldInfoAfter - The world info to be added after the main conversation. * @param {string} content.bias - The bias to be added in the conversation. @@ -1373,7 +1377,7 @@ export async function prepareOpenAIMessages({ name2, charDescription, charPersonality, - Scenario, + scenario, worldInfoBefore, worldInfoAfter, bias, @@ -1400,21 +1404,18 @@ export async function prepareOpenAIMessages({ try { // Merge markers and ordered user prompts with system prompts const prompts = await preparePromptsForChatCompletion({ - Scenario, + scenario, charPersonality, name2, worldInfoBefore, worldInfoAfter, charDescription, quietPrompt, - quietImage, bias, extensionPrompts, systemPromptOverride, jailbreakPromptOverride, personaDescription, - messages, - messageExamples, }); // Fill the chat completion with as much context as the budget allows @@ -1660,6 +1661,8 @@ export function getChatCompletionModel(source = null) { return oai_settings.deepseek_model; case chat_completion_sources.XAI: return oai_settings.xai_model; + case chat_completion_sources.POLLINATIONS: + return oai_settings.pollinations_model; default: console.error(`Unknown chat completion source: ${activeSource}`); return ''; @@ -1842,6 +1845,24 @@ function saveModelList(data) { $('#model_deepseek_select').val(oai_settings.deepseek_model).trigger('change'); } + + if (oai_settings.chat_completion_source === chat_completion_sources.POLLINATIONS) { + $('#model_pollinations_select').empty(); + model_list.forEach((model) => { + $('#model_pollinations_select').append( + $('