diff --git a/lib/Service/OpenAiSettingsService.php b/lib/Service/OpenAiSettingsService.php index cdf11902..8d65d3fb 100644 --- a/lib/Service/OpenAiSettingsService.php +++ b/lib/Service/OpenAiSettingsService.php @@ -391,9 +391,11 @@ public function setMaxTokens(int $maxTokens): void { } public function setLlmExtraParams(string $llmExtraParams): void { - $paramsArray = json_decode($llmExtraParams, true); - if ($paramsArray === null) { - throw new Exception('Invalid model extra parameters'); + if ($llmExtraParams !== '') { + $paramsArray = json_decode($llmExtraParams, true); + if (!is_array($paramsArray)) { + throw new Exception('Invalid model extra parameters, must be a valid JSON object string or an empty string'); + } } $this->config->setAppValue(Application::APP_ID, 'llm_extra_params', $llmExtraParams); }