From c3987073d876eaca7f225b9cd49fb9b1773d63c6 Mon Sep 17 00:00:00 2001 From: Ansible-lightspeed-Bot Date: Fri, 20 Oct 2023 20:10:11 +0530 Subject: [PATCH] Fix to ignore empty model ID * If model ID is set to empty set it to `undefined` and don't send it to the lightspeed endpoint * Trim the model ID value of the whitespaces --- src/settings.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index e2c91f046..1796cfbc9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -40,11 +40,20 @@ export class SettingsManager { suggestions: { enabled: lightSpeedSettings.get("suggestions.enabled", false), }, - model: ( - lightSpeedSettings.get("modelIdOverride")?.trim() - ), + model: lightSpeedSettings.get("modelIdOverride", undefined), }, }; + + // Remove whitespace before and after the model ID and if it is empty, set it to undefined + if ( + typeof this.settings.lightSpeedService.model === "string" && + this.settings.lightSpeedService.model.trim() + ) { + this.settings.lightSpeedService.model = + this.settings.lightSpeedService.model.trim(); + } else { + this.settings.lightSpeedService.model = undefined; + } return; }