Skip to content

Commit

Permalink
chore: don't activate Copilot if a custom OpenAI key has been set
Browse files Browse the repository at this point in the history
  • Loading branch information
jansorg committed Jan 10, 2025
1 parent 7717017 commit 57dcf65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import appland.copilotChat.copilot.GitHubCopilotService;
import appland.rpcService.AppLandJsonRpcService;
import appland.settings.AppMapApplicationSettingsService;
import appland.settings.AppMapSecureApplicationSettingsService;
import com.intellij.ide.plugins.PluginManager;

import java.util.Map;
Expand Down Expand Up @@ -37,7 +38,9 @@ public static boolean isGitHubCopilotIntegrationEnabled() {
*/
public static boolean hasCustomModelSettings() {
var environment = AppMapApplicationSettingsService.getInstance().getCliEnvironment();
return environment.containsKey(AppLandJsonRpcService.OPENAI_API_KEY)
return AppMapSecureApplicationSettingsService.getInstance().hasOpenAIKey()
|| environment.containsKey(AppLandJsonRpcService.OPENAI_API_KEY)
|| environment.containsKey(AppLandJsonRpcService.OPENAI_BASE_URL)
|| environment.containsKey(AppLandJsonRpcService.AZURE_OPENAI_API_KEY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public interface AppLandJsonRpcService extends Disposable {

String OPENAI_API_KEY = "OPENAI_API_KEY";
String AZURE_OPENAI_API_KEY = "AZURE_OPENAI_API_KEY";
String OPENAI_BASE_URL = "OPENAI_BASE_URL";
// all environment variables, which define LLM settings of Navie
Set<String> LLM_ENV_VARIABLES = Set.of(
OPENAI_API_KEY,
"OPENAI_BASE_URL",
OPENAI_BASE_URL,
"APPMAP_NAVIE_MODEL",
"APPMAP_NAVIE_TOKEN_LIMIT",
AZURE_OPENAI_API_KEY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package appland.settings;

import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.Nullable;

public interface AppMapSecureApplicationSettings {
@Nullable
String getOpenAIKey();

void setOpenAIKey(@Nullable String key);

default boolean hasOpenAIKey() {
return StringUtil.isNotEmpty(getOpenAIKey());
}
}

0 comments on commit 57dcf65

Please sign in to comment.