diff --git a/default/settings.json b/default/settings.json
index 73597d741..25b1eebaf 100644
--- a/default/settings.json
+++ b/default/settings.json
@@ -151,6 +151,7 @@
"names_force_groups": true,
"activation_regex": ""
},
+ "default_context": "Default",
"context": {
"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}}",
diff --git a/public/index.html b/public/index.html
index cda9b4711..a5ea80a8f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2090,9 +2090,15 @@
Context Template
-
-
+
+
+
+
+
+
+
+
+
-
@@ -2170,6 +2175,7 @@
Force for Groups and Personas
+
diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js
index 9c21f4bb1..7d4dc2887 100644
--- a/public/scripts/instruct-mode.js
+++ b/public/scripts/instruct-mode.js
@@ -90,7 +90,7 @@ function selectContextPreset(preset) {
}
// 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;
$('#instruct_enabled').prop('checked', true).trigger('change');
toastr.info(`Instruct Mode enabled`);
@@ -359,7 +359,7 @@ jQuery(() => {
$('#instruct_presets').trigger('change');
// When instruct mode gets disabled, select default context preset
} else {
- selectContextPreset('Default');
+ selectContextPreset(power_user.default_context);
}
});
@@ -397,7 +397,7 @@ jQuery(() => {
}
if (!foundMatch) {
// If no match was found, select default context preset
- selectContextPreset('Default');
+ selectContextPreset(power_user.default_context);
}
highlightDefaultPreset();
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js
index 6f5481ff8..21ba317c2 100644
--- a/public/scripts/power-user.js
+++ b/public/scripts/power-user.js
@@ -176,6 +176,7 @@ let power_user = {
activation_regex: "",
},
+ default_context: 'Default',
context: {
preset: 'Default',
story_string: defaultStoryString,
@@ -951,7 +952,31 @@ function loadContextSettings() {
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);
+ $('#context_set_default').toggleClass('disabled', power_user.default_context === power_user.context.preset);
+ $('#context_delete_preset').toggleClass('disabled', power_user.default_context === power_user.context.preset);
}
export function fuzzySearchCharacters(searchValue) {
diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js
index e90602d71..9b30e4273 100644
--- a/public/scripts/preset-manager.js
+++ b/public/scripts/preset-manager.js
@@ -18,7 +18,7 @@ import {
import { groups, selected_group } from "./group-chats.js";
import { instruct_presets } from "./instruct-mode.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 {
textgenerationwebui_preset_names,
textgenerationwebui_presets,
@@ -167,6 +167,10 @@ class PresetManager {
presets = textgenerationwebui_presets;
preset_names = textgenerationwebui_preset_names;
break;
+ case "context":
+ presets = context_presets;
+ preset_names = context_presets.map(x => x.name);
+ break;
case "instruct":
presets = instruct_presets;
preset_names = instruct_presets.map(x => x.name);
@@ -179,11 +183,11 @@ class PresetManager {
}
isKeyedApi() {
- return this.apiId == "textgenerationwebui" || this.apiId == "instruct";
+ return this.apiId == "textgenerationwebui" || this.apiId == "context" || this.apiId == "instruct";
}
isNonGenericApi() {
- return this.apiId == "instruct";
+ return this.apiId == "context" || this.apiId == "instruct";
}
updateList(name, preset) {
@@ -231,10 +235,14 @@ class PresetManager {
return nai_settings;
case "textgenerationwebui":
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":
- const preset = deepClone(power_user.instruct);
- preset['name'] = name || power_user.instruct.preset;
- return preset;
+ const instruct_preset = deepClone(power_user.instruct);
+ instruct_preset['name'] = name || power_user.instruct.preset;
+ return instruct_preset;
default:
console.warn(`Unknown API ID ${apiId}`);
return {};
@@ -391,6 +399,11 @@ jQuery(async () => {
return;
}
+ // default context preset cannot be deleted
+ if (apiId == "context" && power_user.default_context === power_user.context.preset) {
+ return;
+ }
+
const confirm = await callPopup('Delete the preset? This action is irreversible and your current settings will be overwritten.', 'confirm');
if (!confirm) {
diff --git a/public/style.css b/public/style.css
index 08d3edd5c..3f09e4c76 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1291,6 +1291,10 @@ select option:not(:checked) {
color: var(--active) !important;
}
+#context_set_default.default {
+ color: var(--preferred) !important;
+}
+
#instruct_set_default.default {
color: var(--preferred) !important;
}
diff --git a/server.js b/server.js
index ed87518cb..ed3dad483 100644
--- a/server.js
+++ b/server.js
@@ -3835,6 +3835,8 @@ function getPresetSettingsByAPI(apiId) {
return { folder: directories.textGen_Settings, extension: '.settings' };
case 'instruct':
return { folder: directories.instruct, extension: '.json' };
+ case 'context':
+ return { folder: directories.context, extension: '.json' };
default:
return { folder: null, extension: null };
}