Cohere: limit penalties

e8de36a0d019b16bf354afe8ed4e38aa9a3ea1d3

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +15 -0Ignore whitespace
public/scripts/openai.js+15 -0
@@ -1372,6 +1372,11 @@ function tryParseStreamingError(response, decoded) {
13721372 toastr.error(data.error.message || response.statusText, 'Chat Completion API');
13731373 throw new Error(data);
13741374 }
1375+
1376+ if (data.message) {
1377+ toastr.error(data.message, 'Chat Completion API');
1378+ throw new Error(data);
1379+ }
13751380 }
13761381 catch {
13771382 // No JSON. Do nothing.
@@ -4324,6 +4329,16 @@ async function onModelChange() {
43244329 $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
43254330 }
43264331
4332+ if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) {
4333+ oai_settings.pres_pen_openai = Math.min(Math.max(0, oai_settings.pres_pen_openai), 1);
4334+ $('#pres_pen_openai').attr('max', 1).attr('min', 0).val(oai_settings.pres_pen_openai).trigger('input');
4335+ oai_settings.freq_pen_openai = Math.min(Math.max(0, oai_settings.freq_pen_openai), 1);
4336+ $('#freq_pen_openai').attr('max', 1).attr('min', 0).val(oai_settings.freq_pen_openai).trigger('input');
4337+ } else {
4338+ $('#pres_pen_openai').attr('max', 2).attr('min', 0).val(oai_settings.pres_pen_openai).trigger('input');
4339+ $('#freq_pen_openai').attr('max', 2).attr('min', 0).val(oai_settings.freq_pen_openai).trigger('input');
4340+ }
4341+
43274342 $('#openai_max_context_counter').attr('max', Number($('#openai_max_context').attr('max')));
43284343
43294344 saveSettingsDebounced();