From c3c0bc2ce6cf739b46f48ca4f5e61d90861a2ad6 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Mon, 6 May 2024 13:19:04 +0200 Subject: [PATCH] allow empty string for extra llm params Signed-off-by: Julien Veyssier --- lib/Service/OpenAiSettingsService.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); }