From b385bd190ac3aaab6d969090dd041f65dabde156 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 23 Aug 2023 03:41:58 +0300 Subject: [PATCH] Less strict rules for logit bias files import --- public/scripts/openai.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 1b62a8336..cb091880f 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -2324,18 +2324,17 @@ async function onLogitBiasPresetImportFileChange(e) { return; } + const validEntries = []; + for (const entry of importedFile) { - if (typeof entry == 'object') { + if (typeof entry == 'object' && entry !== null) { if (entry.hasOwnProperty('text') && entry.hasOwnProperty('value')) { - continue; + validEntries.push(entry); } } - - callPopup('Invalid logit bias preset file.', 'text'); - return; } - oai_settings.bias_presets[name] = importedFile; + oai_settings.bias_presets[name] = validEntries; oai_settings.bias_preset_selected = name; addLogitBiasPresetOption(name);