mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add /preset command
This commit is contained in:
@ -2478,28 +2478,6 @@ function showWindowExtensionError() {
|
||||
});
|
||||
}
|
||||
|
||||
function trySelectPresetByName(name) {
|
||||
let preset_found = null;
|
||||
for (const key in openai_setting_names) {
|
||||
if (name.trim() == key.trim()) {
|
||||
preset_found = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't change if the current preset is the same
|
||||
if (preset_found && preset_found === oai_settings.preset_settings_openai) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (preset_found) {
|
||||
oai_settings.preset_settings_openai = preset_found;
|
||||
const value = openai_setting_names[preset_found];
|
||||
$(`#settings_preset_openai option[value="${value}"]`).attr('selected', true);
|
||||
$('#settings_preset_openai').val(value).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a settings preset with the given name
|
||||
*
|
||||
@ -3573,29 +3551,6 @@ $(document).ready(async function () {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
// auto-select a preset based on character/group name
|
||||
$(document).on('click', '.character_select', function () {
|
||||
const chid = $(this).attr('chid');
|
||||
const name = characters[chid]?.name;
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
trySelectPresetByName(name);
|
||||
});
|
||||
|
||||
$(document).on('click', '.group_select', function () {
|
||||
const grid = $(this).data('id');
|
||||
const name = groups.find(x => x.id === grid)?.name;
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
trySelectPresetByName(name);
|
||||
});
|
||||
|
||||
$('#update_oai_preset').on('click', async function () {
|
||||
const name = oai_settings.preset_settings_openai;
|
||||
await saveOpenAIPreset(name, oai_settings);
|
||||
|
Reference in New Issue
Block a user