mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-31 11:35:37 +01:00
context template preset manager
This commit is contained in:
parent
bca44ba682
commit
1d7165c047
@ -151,6 +151,7 @@
|
|||||||
"names_force_groups": true,
|
"names_force_groups": true,
|
||||||
"activation_regex": ""
|
"activation_regex": ""
|
||||||
},
|
},
|
||||||
|
"default_context": "Default",
|
||||||
"context": {
|
"context": {
|
||||||
"preset": "Default",
|
"preset": "Default",
|
||||||
"story_string": "{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
|
"story_string": "{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
|
||||||
|
@ -2090,9 +2090,15 @@
|
|||||||
<h4 data-i18n="Context Template">
|
<h4 data-i18n="Context Template">
|
||||||
Context Template
|
Context Template
|
||||||
</h4>
|
</h4>
|
||||||
<div class="flex-container flexGap5">
|
<div class="preset_buttons">
|
||||||
<select id="context_presets" class="flex1 margin0">
|
<select id="context_presets" data-preset-manager-for="context" class="flex1"></select>
|
||||||
</select>
|
<input type="file" hidden data-preset-manager-file="context" accept=".json, .settings">
|
||||||
|
<i id="context_set_default" class="menu_button fa-solid fa-heart" title="Auto-select this preset on API connection."></i>
|
||||||
|
<i data-preset-manager-update="context" class="menu_button fa-solid fa-save" title="Update current preset" data-i18n="[title]Update current preset"></i>
|
||||||
|
<i data-preset-manager-new="context" class="menu_button fa-solid fa-plus" title="Create new preset" data-i18n="[title]Create new preset"></i>
|
||||||
|
<i data-preset-manager-import="context" class="menu_button fa-solid fa-file-import" title="Import preset" data-i18n="[title]Import preset"></i>
|
||||||
|
<i data-preset-manager-export="context" class="menu_button fa-solid fa-file-export" title="Export preset" data-i18n="[title]Export preset"></i>
|
||||||
|
<i data-preset-manager-delete="context" class="menu_button fa-solid fa-trash-can" title="Delete the preset" data-i18n="[title]Delete the preset"></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="context_story_string">
|
<label for="context_story_string">
|
||||||
|
@ -90,7 +90,7 @@ function selectContextPreset(preset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If instruct mode is disabled, enable it, except for default context template
|
// If instruct mode is disabled, enable it, except for default context template
|
||||||
if (!power_user.instruct.enabled && preset !== 'Default') {
|
if (!power_user.instruct.enabled && preset !== power_user.default_context) {
|
||||||
power_user.instruct.enabled = true;
|
power_user.instruct.enabled = true;
|
||||||
$('#instruct_enabled').prop('checked', true).trigger('change');
|
$('#instruct_enabled').prop('checked', true).trigger('change');
|
||||||
toastr.info(`Instruct Mode enabled`);
|
toastr.info(`Instruct Mode enabled`);
|
||||||
@ -359,7 +359,7 @@ jQuery(() => {
|
|||||||
$('#instruct_presets').trigger('change');
|
$('#instruct_presets').trigger('change');
|
||||||
// When instruct mode gets disabled, select default context preset
|
// When instruct mode gets disabled, select default context preset
|
||||||
} else {
|
} else {
|
||||||
selectContextPreset('Default');
|
selectContextPreset(power_user.default_context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ jQuery(() => {
|
|||||||
}
|
}
|
||||||
if (!foundMatch) {
|
if (!foundMatch) {
|
||||||
// If no match was found, select default context preset
|
// If no match was found, select default context preset
|
||||||
selectContextPreset('Default');
|
selectContextPreset(power_user.default_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
highlightDefaultPreset();
|
highlightDefaultPreset();
|
||||||
|
@ -176,6 +176,7 @@ let power_user = {
|
|||||||
activation_regex: "",
|
activation_regex: "",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
default_context: 'Default',
|
||||||
context: {
|
context: {
|
||||||
preset: 'Default',
|
preset: 'Default',
|
||||||
story_string: defaultStoryString,
|
story_string: defaultStoryString,
|
||||||
@ -951,7 +952,29 @@ function loadContextSettings() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
highlightDefaultContext();
|
||||||
|
|
||||||
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#context_set_default').on('click', function () {
|
||||||
|
if (power_user.context.preset !== power_user.default_context) {
|
||||||
|
power_user.default_context = power_user.context.preset;
|
||||||
|
$(this).addClass('default');
|
||||||
|
toastr.info(`Default context template set to ${power_user.default_context}`);
|
||||||
|
|
||||||
|
highlightDefaultContext();
|
||||||
|
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
highlightDefaultContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightDefaultContext() {
|
||||||
|
$('#context_set_default').toggleClass('default', power_user.default_context === power_user.context.preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fuzzySearchCharacters(searchValue) {
|
export function fuzzySearchCharacters(searchValue) {
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
import { groups, selected_group } from "./group-chats.js";
|
import { groups, selected_group } from "./group-chats.js";
|
||||||
import { instruct_presets } from "./instruct-mode.js";
|
import { instruct_presets } from "./instruct-mode.js";
|
||||||
import { kai_settings } from "./kai-settings.js";
|
import { kai_settings } from "./kai-settings.js";
|
||||||
import { power_user } from "./power-user.js";
|
import { context_presets, power_user } from "./power-user.js";
|
||||||
import {
|
import {
|
||||||
textgenerationwebui_preset_names,
|
textgenerationwebui_preset_names,
|
||||||
textgenerationwebui_presets,
|
textgenerationwebui_presets,
|
||||||
@ -167,6 +167,10 @@ class PresetManager {
|
|||||||
presets = textgenerationwebui_presets;
|
presets = textgenerationwebui_presets;
|
||||||
preset_names = textgenerationwebui_preset_names;
|
preset_names = textgenerationwebui_preset_names;
|
||||||
break;
|
break;
|
||||||
|
case "context":
|
||||||
|
presets = context_presets;
|
||||||
|
preset_names = context_presets.map(x => x.name);
|
||||||
|
break;
|
||||||
case "instruct":
|
case "instruct":
|
||||||
presets = instruct_presets;
|
presets = instruct_presets;
|
||||||
preset_names = instruct_presets.map(x => x.name);
|
preset_names = instruct_presets.map(x => x.name);
|
||||||
@ -179,11 +183,11 @@ class PresetManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isKeyedApi() {
|
isKeyedApi() {
|
||||||
return this.apiId == "textgenerationwebui" || this.apiId == "instruct";
|
return this.apiId == "textgenerationwebui" || this.apiId == "context" || this.apiId == "instruct";
|
||||||
}
|
}
|
||||||
|
|
||||||
isNonGenericApi() {
|
isNonGenericApi() {
|
||||||
return this.apiId == "instruct";
|
return this.apiId == "context" || this.apiId == "instruct";
|
||||||
}
|
}
|
||||||
|
|
||||||
updateList(name, preset) {
|
updateList(name, preset) {
|
||||||
@ -231,10 +235,14 @@ class PresetManager {
|
|||||||
return nai_settings;
|
return nai_settings;
|
||||||
case "textgenerationwebui":
|
case "textgenerationwebui":
|
||||||
return textgenerationwebui_settings;
|
return textgenerationwebui_settings;
|
||||||
|
case "context":
|
||||||
|
const context_preset = deepClone(power_user.context);
|
||||||
|
context_preset['name'] = name || power_user.context.preset;
|
||||||
|
return context_preset;
|
||||||
case "instruct":
|
case "instruct":
|
||||||
const preset = deepClone(power_user.instruct);
|
const instruct_preset = deepClone(power_user.instruct);
|
||||||
preset['name'] = name || power_user.instruct.preset;
|
instruct_preset['name'] = name || power_user.instruct.preset;
|
||||||
return preset;
|
return instruct_preset;
|
||||||
default:
|
default:
|
||||||
console.warn(`Unknown API ID ${apiId}`);
|
console.warn(`Unknown API ID ${apiId}`);
|
||||||
return {};
|
return {};
|
||||||
|
@ -1291,6 +1291,10 @@ select option:not(:checked) {
|
|||||||
color: var(--active) !important;
|
color: var(--active) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#context_set_default.default {
|
||||||
|
color: var(--preferred) !important;
|
||||||
|
}
|
||||||
|
|
||||||
#instruct_set_default.default {
|
#instruct_set_default.default {
|
||||||
color: var(--preferred) !important;
|
color: var(--preferred) !important;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user