respect context unlocked flag when auto-setting context size
Signed| @@ -1256,12 +1256,13 @@ async function getStatusTextgen() { | ||
| 1256 | 1256 | const { chat_template, chat_template_hash } = data; |
| 1257 | 1257 | if (wantsContextSize && "default_generation_settings" in data) { |
| 1258 | 1258 | const backend_max_context = data["default_generation_settings"]["n_ctx"]; |
| 1259 | + const old_value = max_context; | |
| 1259 | 1260 | if (max_context !== backend_max_context) { |
| 1260 | - console.log(`Auto-switching max context from ${max_context} to ${backend_max_context}`); | |
| 1261 | + setGenerationParamsFromPreset({ max_length: backend_max_context }, true); | |
| 1261 | - toastr.info(`Context Size Changed: ${max_context} ⇒ ${backend_max_context}`); | |
| 1262 | + } | |
| 1262 | - max_context = backend_max_context; | |
| 1263 | + if (old_value !== max_context) { | |
| 1263 | - $('#max_context').val(max_context); | |
| 1264 | + console.log(`Auto-switched max context from ${old_value} to ${max_context}`); | |
| 1264 | - $('#max_context_counter').val(max_context); | |
| 1265 | + toastr.info(`Context Size Changed: ${old_value} ⇒ ${max_context}`); | |
| 1265 | 1266 | } |
| 1266 | 1267 | } |
| 1267 | 1268 | console.log(`We have chat template ${chat_template.split('\n')[0]}...`); |
| @@ -6832,9 +6833,19 @@ export async function saveSettings(type) { | ||
| 6832 | 6833 | }); |
| 6833 | 6834 | } |
| 6834 | 6835 | |
| 6835 | 6836 | export function setGenerationParamsFromPreset(preset, keep_context_lock) { |
| 6836 | 6837 | const needsUnlock = (preset.max_length ?? max_context) > MAX_CONTEXT_DEFAULT || (preset.genamt ?? amount_gen) > MAX_RESPONSE_DEFAULT; |
| 6837 | 6838 | if (!keep_context_lock || $('#max_context_unlocked').prop('checked', needsUnlock).trigger('change'); { |
| 6839 | + $('#max_context_unlocked').prop('checked', needsUnlock).trigger('change'); | |
| 6840 | + } else if (needsUnlock) { | |
| 6841 | + // cap values | |
| 6842 | + if ((preset.max_length ?? max_context) > MAX_CONTEXT_DEFAULT) { | |
| 6843 | + preset.max_length = MAX_CONTEXT_DEFAULT; | |
| 6844 | + } | |
| 6845 | + if ((preset.genamt ?? amount_gen) > MAX_RESPONSE_DEFAULT) { | |
| 6846 | + preset.genamt = MAX_RESPONSE_DEFAULT; | |
| 6847 | + } | |
| 6848 | + } | |
| 6838 | 6849 | |
| 6839 | 6850 | if (preset.genamt !== undefined) { |
| 6840 | 6851 | amount_gen = preset.genamt; |