From d4faaadcc8a7e335e5d42db046b872fab3a6e9a0 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 29 May 2024 14:42:30 +0200 Subject: [PATCH] fix: incorrect numeric settings handling on the server side Signed-off-by: Julien Veyssier --- lib/Service/OpenAiSettingsService.php | 7 ++++-- src/components/AdminSettings.vue | 33 +++++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/Service/OpenAiSettingsService.php b/lib/Service/OpenAiSettingsService.php index 8d65d3fb..451c163c 100644 --- a/lib/Service/OpenAiSettingsService.php +++ b/lib/Service/OpenAiSettingsService.php @@ -462,8 +462,11 @@ public function setUseBasicAuth(bool $useBasicAuth): void { public function setAdminConfig(array $adminConfig): void { // That the variable types are correct foreach (array_keys($adminConfig) as $key) { - if (gettype($adminConfig[$key]) !== self::ADMIN_CONFIG_TYPES[$key]) { - throw new Exception('Invalid type for key: ' . $key . '. Expected ' . self::ADMIN_CONFIG_TYPES[$key] . ', got ' . gettype($adminConfig[$key])); + $value = $adminConfig[$key]; + if ($value === null) { + $this->config->deleteAppValue(Application::APP_ID, $key); + } elseif (gettype($value) !== self::ADMIN_CONFIG_TYPES[$key]) { + throw new Exception('Invalid type for key: ' . $key . '. Expected ' . self::ADMIN_CONFIG_TYPES[$key] . ', got ' . gettype($value)); } } diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index b5054a2a..5ab0ffd3 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -209,7 +209,7 @@
- - + +
@@ -229,7 +232,7 @@
- + @trailing-button-click="state.quota_period = '' ; onInput(false)"> + +
@@ -282,7 +289,7 @@
- + @trailing-button-click="state.max_tokens = '' ; onInput(false)"> + +