Merge branch 'staging' into ffmpeg-videobg

This commit is contained in:
Cohee
2025-04-09 19:37:11 +03:00
32 changed files with 248 additions and 140 deletions

View File

@@ -459,7 +459,7 @@ export async function appendFileContent(message, messageText) {
* @copyright https://github.com/kwaroran/risuAI
*/
export function encodeStyleTags(text) {
const styleRegex = /<style>(.+?)<\/style>/gms;
const styleRegex = /<style>(.+?)<\/style>/gims;
return text.replaceAll(styleRegex, (_, match) => {
return `<custom-style>${escape(match)}</custom-style>`;
});

View File

@@ -65,6 +65,7 @@
<option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option>
<option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option>
<option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option>
<option data-type="google" value="gemini-2.5-pro-preview-03-25">gemini-2.5-pro-preview-03-25</option>
<option data-type="google" value="gemini-2.5-pro-exp-03-25">gemini-2.5-pro-exp-03-25</option>
<option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option>
<option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05</option>

View File

@@ -180,13 +180,18 @@ function displayError(message) {
* Preserves the query string.
*/
function redirectToHome() {
// After a login theres no need to preserve the
// noauto (if present)
const urlParams = new URLSearchParams(window.location.search);
// Create a URL object based on the current location
const currentUrl = new URL(window.location.href);
urlParams.delete('noauto');
// After a login there's no need to preserve the
// noauto parameter (if present)
currentUrl.searchParams.delete('noauto');
window.location.href = '/' + urlParams.toString();
// Set the pathname to root and keep the updated query string
currentUrl.pathname = '/';
// Redirect to the new URL
window.location.href = currentUrl.toString();
}
/**

View File

@@ -4193,6 +4193,9 @@ function getGroqMaxContext(model, isUnlocked) {
'qwen-2.5-32b': max_128k,
'deepseek-r1-distill-qwen-32b': max_128k,
'deepseek-r1-distill-llama-70b-specdec': max_128k,
'mistral-saba-24b': max_32k,
'meta-llama/llama-4-scout-17b-16e-instruct': max_128k,
'meta-llama/llama-4-maverick-17b-128e-instruct': max_128k,
};
// Return context size if model found, otherwise default to 128k
@@ -4327,7 +4330,7 @@ async function onModelChange() {
$('#openai_max_context').attr('max', max_32k);
} else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206') || value.includes('gemini-2.0-pro')) {
$('#openai_max_context').attr('max', max_2mil);
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash') || value.includes('gemini-2.5-pro-exp-03-25')) {
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash') || value.includes('gemini-2.5-pro-exp-03-25') || value.includes('gemini-2.5-pro-preview-03-25')) {
$('#openai_max_context').attr('max', max_1mil);
} else if (value.includes('gemini-1.0-pro') || value === 'gemini-pro') {
$('#openai_max_context').attr('max', max_32k);
@@ -4961,6 +4964,7 @@ export function isImageInliningSupported() {
const visionSupportedModels = [
'gpt-4-vision',
'gemini-2.5-pro-exp-03-25',
'gemini-2.5-pro-preview-03-25',
'gemini-2.0-pro-exp',
'gemini-2.0-pro-exp-02-05',
'gemini-2.0-flash-lite-preview',

View File

@@ -36,7 +36,7 @@ import {
textgenerationwebui_presets,
textgenerationwebui_settings as textgen_settings,
} from './textgen-settings.js';
import { download, parseJsonFile, waitUntilCondition } from './utils.js';
import { download, equalsIgnoreCaseAndAccents, parseJsonFile, waitUntilCondition } from './utils.js';
import { t } from './i18n.js';
import { reasoning_templates } from './reasoning.js';
@@ -454,6 +454,9 @@ class PresetManager {
async renamePreset(newName) {
const oldName = this.getSelectedPresetName();
if (equalsIgnoreCaseAndAccents(oldName, newName)) {
throw new Error('New name must be different from old name');
}
try {
await this.savePreset(newName);
await this.deletePreset(oldName);
@@ -892,6 +895,10 @@ export async function initPresetManager() {
console.debug(!presetManager.isAdvancedFormatting() ? 'Preset rename cancelled' : 'Template rename cancelled');
return;
}
if (equalsIgnoreCaseAndAccents(oldName, newName)) {
toastr.warning(t`Name not accepted, as it is the same as before (ignoring case and accents).`, t`Rename Preset`);
return;
}
await presetManager.renamePreset(newName);

View File

@@ -832,6 +832,12 @@ function registerReasoningSlashCommands() {
typeList: ARGUMENT_TYPE.NUMBER,
enumProvider: commonEnumProviders.messages(),
}),
SlashCommandNamedArgument.fromProps({
name: 'collapse',
description: 'Whether to collapse the reasoning block. (If not provided, uses the default expand setting)',
typeList: [ARGUMENT_TYPE.BOOLEAN],
enumList: commonEnumProviders.boolean('trueFalse')(),
}),
],
unnamedArgumentList: [
SlashCommandArgument.fromProps({
@@ -856,6 +862,9 @@ function registerReasoningSlashCommands() {
closeMessageEditor('reasoning');
updateMessageBlock(messageId, message);
if (isTrueBoolean(String(args.collapse))) $(`#chat [mesid="${messageId}"] .mes_reasoning_details`).removeAttr('open');
if (isFalseBoolean(String(args.collapse))) $(`#chat [mesid="${messageId}"] .mes_reasoning_details`).attr('open', '');
return message.extra.reasoning;
},
}));

View File

@@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => {
return [{
type: 'output',
regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
replace: function(match, codeContent, italicContent) {
if (codeContent) {
// If it's inside <code> tags, return unchanged
regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>|<style(?:\\s+[^>]*)?>[\\s\\S]*?<\\/style>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gi'),
replace: function(match, tagContent, italicContent) {
if (tagContent) {
// If it's inside <code> or <style> tags, return unchanged
return match;
} else if (italicContent) {
// If it's an italic group, apply the replacement

View File

@@ -9,8 +9,8 @@ import { ensureImageFormatSupported, getBase64Async, humanFileSize } from './uti
export let currentUser = null;
export let accountsEnabled = false;
// Extend the session every 30 minutes
const SESSION_EXTEND_INTERVAL = 30 * 60 * 1000;
// Extend the session every 10 minutes
const SESSION_EXTEND_INTERVAL = 10 * 60 * 1000;
/**
* Enable or disable user account controls in the UI.

View File

@@ -1,7 +1,7 @@
import { Fuse } from '../lib.js';
import { saveSettings, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js';
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce, findChar, onlyUnique } from './utils.js';
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce, findChar, onlyUnique, equalsIgnoreCaseAndAccents } from './utils.js';
import { extension_settings, getContext } from './extensions.js';
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
import { isMobile } from './RossAscends-mods.js';
@@ -3586,6 +3586,10 @@ async function renameWorldInfo(name, data) {
console.debug('World info rename cancelled');
return;
}
if (equalsIgnoreCaseAndAccents(oldName, newName)) {
toastr.warning(t`Name not accepted, as it is the same as before (ignoring case and accents).`, t`Rename World Info`);
return;
}
const entryPreviouslySelected = selected_world_info.findIndex((e) => e === oldName);