From e91cbe009f38784839e95ba2a3ef7f2ab1bb33bc Mon Sep 17 00:00:00 2001 From: Cohee Date: Thu, 15 Jun 2023 18:32:56 +0300 Subject: [PATCH] Correctly clamp max_context value on saving a chat completion preset --- public/scripts/openai.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 6676fbed9..cabfcc872 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1490,10 +1490,11 @@ function onModelChange() { } else { $('#openai_max_context').attr('max', claude_max); - oai_settings.openai_max_context = Math.max(oai_settings.openai_max_context, claude_max); - $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); } + oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); + $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); + $('#openai_reverse_proxy').attr('placeholder', 'https://api.anthropic.com/v1'); oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai); @@ -1527,7 +1528,7 @@ function onModelChange() { $('#openai_max_context').attr('max', gpt3_max); } - oai_settings.openai_max_context = Math.max(Number($('#openai_max_context').val()), oai_settings.openai_max_context); + oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context); $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); if (value.includes('claude')) { @@ -1557,7 +1558,7 @@ function onModelChange() { $('#openai_max_context').attr('max', gpt3_max); } - oai_settings.openai_max_context = Math.max(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); + oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); $('#openai_reverse_proxy').attr('placeholder', 'https://api.openai.com/v1');