From a9e147ffc777642c56127fa4caf0bc6218cca3f3 Mon Sep 17 00:00:00 2001 From: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:24:44 +0200 Subject: [PATCH] fix: NPE when using unsupported model for code completions (#499) --- .../codegpt/settings/service/llama/LlamaSettings.java | 10 ++++++++++ .../actions/CodeCompletionFeatureToggleActions.kt | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/ee/carlrobert/codegpt/settings/service/llama/LlamaSettings.java b/src/main/java/ee/carlrobert/codegpt/settings/service/llama/LlamaSettings.java index ef952d2f..c27edac9 100644 --- a/src/main/java/ee/carlrobert/codegpt/settings/service/llama/LlamaSettings.java +++ b/src/main/java/ee/carlrobert/codegpt/settings/service/llama/LlamaSettings.java @@ -6,6 +6,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; +import ee.carlrobert.codegpt.completions.llama.LlamaModel; import ee.carlrobert.codegpt.credentials.CredentialsStore; import ee.carlrobert.codegpt.settings.service.llama.form.LlamaSettingsForm; import org.apache.commons.lang3.StringUtils; @@ -31,6 +32,15 @@ public class LlamaSettings implements PersistentStateComponent OpenAISettings.getCurrentState().isCodeCompletionsEnabled CUSTOM_OPENAI -> service().state.codeCompletionSettings.codeCompletionsEnabled - LLAMA_CPP -> LlamaSettings.getCurrentState().isCodeCompletionsEnabled + LLAMA_CPP -> LlamaSettings.isCodeCompletionsPossible() else -> false } } @@ -57,4 +57,4 @@ abstract class CodeCompletionFeatureToggleActions( class EnableCompletionsAction : CodeCompletionFeatureToggleActions(true) -class DisableCompletionsAction : CodeCompletionFeatureToggleActions(false) \ No newline at end of file +class DisableCompletionsAction : CodeCompletionFeatureToggleActions(false)