mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Adjust reasoning template migration procedure
This commit is contained in:
@@ -55,7 +55,7 @@ import { POPUP_TYPE, callGenericPopup } from './popup.js';
|
|||||||
import { loadSystemPrompts } from './sysprompt.js';
|
import { loadSystemPrompts } from './sysprompt.js';
|
||||||
import { fuzzySearchCategories } from './filters.js';
|
import { fuzzySearchCategories } from './filters.js';
|
||||||
import { accountStorage } from './util/AccountStorage.js';
|
import { accountStorage } from './util/AccountStorage.js';
|
||||||
import { loadReasoningTemplates } from './reasoning.js';
|
import { DEFAULT_REASONING_TEMPLATE, loadReasoningTemplates } from './reasoning.js';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
loadPowerUserSettings,
|
loadPowerUserSettings,
|
||||||
@@ -258,7 +258,7 @@ let power_user = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reasoning: {
|
reasoning: {
|
||||||
name: 'DeepSeek',
|
name: DEFAULT_REASONING_TEMPLATE,
|
||||||
auto_parse: false,
|
auto_parse: false,
|
||||||
add_to_prompts: false,
|
add_to_prompts: false,
|
||||||
auto_expand: false,
|
auto_expand: false,
|
||||||
|
@@ -8,6 +8,7 @@ import { MacrosParser } from './macros.js';
|
|||||||
import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';
|
import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';
|
||||||
import { Popup } from './popup.js';
|
import { Popup } from './popup.js';
|
||||||
import { performFuzzySearch, power_user } from './power-user.js';
|
import { performFuzzySearch, power_user } from './power-user.js';
|
||||||
|
import { getPresetManager } from './preset-manager.js';
|
||||||
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
|
||||||
import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
|
import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
|
||||||
@@ -29,6 +30,8 @@ import { copyText, escapeRegex, isFalseBoolean, isTrueBoolean, setDatasetPropert
|
|||||||
*/
|
*/
|
||||||
export const reasoning_templates = [];
|
export const reasoning_templates = [];
|
||||||
|
|
||||||
|
export const DEFAULT_REASONING_TEMPLATE = 'DeepSeek';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Record<string, JQuery<HTMLElement>>} List of UI elements for reasoning settings
|
* @type {Record<string, JQuery<HTMLElement>>} List of UI elements for reasoning settings
|
||||||
* @readonly
|
* @readonly
|
||||||
@@ -1337,8 +1340,30 @@ export async function loadReasoningTemplates(data) {
|
|||||||
$('<option>').val(template.name).text(template.name).appendTo(UI.$select);
|
$('<option>').val(template.name).text(template.name).appendTo(UI.$select);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!power_user.reasoning.name) {
|
// No template name, need to migrate
|
||||||
power_user.reasoning.name = reasoning_templates[0]?.name ?? '';
|
if (power_user.reasoning.name === undefined) {
|
||||||
|
const defaultTemplate = reasoning_templates.find(p => p.name === DEFAULT_REASONING_TEMPLATE);
|
||||||
|
if (defaultTemplate) {
|
||||||
|
// If the reasoning settings were modified - migrate them to a custom template
|
||||||
|
if (power_user.reasoning.prefix !== defaultTemplate.prefix || power_user.reasoning.suffix !== defaultTemplate.suffix || power_user.reasoning.separator !== defaultTemplate.separator) {
|
||||||
|
/** @type {ReasoningTemplate} */
|
||||||
|
const data = {
|
||||||
|
name: '[Migrated] Custom',
|
||||||
|
prefix: power_user.reasoning.prefix,
|
||||||
|
suffix: power_user.reasoning.suffix,
|
||||||
|
separator: power_user.reasoning.separator,
|
||||||
|
};
|
||||||
|
await getPresetManager('reasoning')?.savePreset(data.name, data);
|
||||||
|
power_user.reasoning.name = data.name;
|
||||||
|
} else {
|
||||||
|
power_user.reasoning.name = defaultTemplate.name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Template not found (deleted or content check skipped - leave blank)
|
||||||
|
power_user.reasoning.name = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.$select.val(power_user.reasoning.name);
|
UI.$select.val(power_user.reasoning.name);
|
||||||
|
Reference in New Issue
Block a user