diff --git a/src/main/java/ee/carlrobert/codegpt/Icons.java b/src/main/java/ee/carlrobert/codegpt/Icons.java index 8a24ad3d..d8d5e584 100644 --- a/src/main/java/ee/carlrobert/codegpt/Icons.java +++ b/src/main/java/ee/carlrobert/codegpt/Icons.java @@ -16,7 +16,6 @@ public final class Icons { public static final Icon ExpandAll = IconLoader.getIcon("/icons/expandAll.svg", Icons.class); public static final Icon Anthropic = IconLoader.getIcon("/icons/anthropic.svg", Icons.class); - public static final Icon Azure = IconLoader.getIcon("/icons/azure.svg", Icons.class); public static final Icon DeepSeek = IconLoader.getIcon("/icons/deepseek.png", Icons.class); public static final Icon Qwen = IconLoader.getIcon("/icons/qwen.png", Icons.class); public static final Icon Google = IconLoader.getIcon("/icons/google.svg", Icons.class); @@ -27,7 +26,6 @@ public final class Icons { public static final Icon Mistral = IconLoader.getIcon("/icons/mistral.svg", Icons.class); public static final Icon Send = IconLoader.getIcon("/icons/send.svg", Icons.class); public static final Icon Sparkle = IconLoader.getIcon("/icons/sparkle.svg", Icons.class); - public static final Icon You = IconLoader.getIcon("/icons/you.svg", Icons.class); public static final Icon Ollama = IconLoader.getIcon("/icons/ollama.svg", Icons.class); public static final Icon User = IconLoader.getIcon("/icons/user.svg", Icons.class); public static final Icon Tree = IconLoader.getIcon("/icons/tree.svg", Icons.class); diff --git a/src/main/java/ee/carlrobert/codegpt/completions/CompletionClientProvider.java b/src/main/java/ee/carlrobert/codegpt/completions/CompletionClientProvider.java index f8401ebd..622e2fc4 100644 --- a/src/main/java/ee/carlrobert/codegpt/completions/CompletionClientProvider.java +++ b/src/main/java/ee/carlrobert/codegpt/completions/CompletionClientProvider.java @@ -7,13 +7,10 @@ import com.intellij.util.net.ssl.CertificateManager; import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey; import ee.carlrobert.codegpt.settings.advanced.AdvancedSettings; import ee.carlrobert.codegpt.settings.service.anthropic.AnthropicSettings; -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings; import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings; import ee.carlrobert.codegpt.settings.service.ollama.OllamaSettings; import ee.carlrobert.codegpt.settings.service.openai.OpenAISettings; import ee.carlrobert.llm.client.anthropic.ClaudeClient; -import ee.carlrobert.llm.client.azure.AzureClient; -import ee.carlrobert.llm.client.azure.AzureCompletionRequestParams; import ee.carlrobert.llm.client.codegpt.CodeGPTClient; import ee.carlrobert.llm.client.google.GoogleClient; import ee.carlrobert.llm.client.llama.LlamaClient; @@ -42,28 +39,13 @@ public class CompletionClientProvider { public static ClaudeClient getClaudeClient() { var builder = new ClaudeClient.Builder(getCredential(CredentialKey.AnthropicApiKey.INSTANCE), - AnthropicSettings.getCurrentState().getApiVersion()); + AnthropicSettings.getCurrentState().getApiVersion()); if (AnthropicSettings.getCurrentState().hasCustomBaseHost()) { builder.setHost(AnthropicSettings.getCurrentState().getBaseHost()); } return builder.build(getDefaultClientBuilder()); } - public static AzureClient getAzureClient() { - var settings = AzureSettings.getCurrentState(); - var params = new AzureCompletionRequestParams( - settings.getResourceName(), - settings.getDeploymentId(), - settings.getApiVersion()); - var useAzureActiveDirectoryAuthentication = settings.isUseAzureActiveDirectoryAuthentication(); - var credential = useAzureActiveDirectoryAuthentication - ? getCredential(CredentialKey.AzureActiveDirectoryToken.INSTANCE) - : getCredential(CredentialKey.AzureOpenaiApiKey.INSTANCE); - return new AzureClient.Builder(credential, params) - .setActiveDirectoryAuthentication(useAzureActiveDirectoryAuthentication) - .build(getDefaultClientBuilder()); - } - public static LlamaClient getLlamaClient() { var llamaSettings = LlamaSettings.getCurrentState(); var builder = new LlamaClient.Builder() diff --git a/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestService.java b/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestService.java index bebe02bb..e2f12052 100644 --- a/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestService.java +++ b/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestService.java @@ -8,7 +8,6 @@ import ee.carlrobert.codegpt.credentials.CredentialsStore; import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey; import ee.carlrobert.codegpt.settings.GeneralSettings; import ee.carlrobert.codegpt.settings.service.ServiceType; -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings; import ee.carlrobert.codegpt.settings.service.google.GoogleSettings; import ee.carlrobert.llm.client.DeserializationUtil; import ee.carlrobert.llm.client.anthropic.completion.ClaudeCompletionRequest; @@ -104,8 +103,6 @@ public final class CompletionRequestService { return switch (GeneralSettings.getSelectedService()) { case OPENAI -> CompletionClientProvider.getOpenAIClient() .getChatCompletionAsync(completionRequest, eventListener); - case AZURE -> CompletionClientProvider.getAzureClient() - .getChatCompletionAsync(completionRequest, eventListener); case OLLAMA -> CompletionClientProvider.getOllamaClient() .getChatCompletionAsync(completionRequest, eventListener); default -> throw new RuntimeException("Unknown service selected"); @@ -145,8 +142,6 @@ public final class CompletionRequestService { var response = switch (GeneralSettings.getSelectedService()) { case OPENAI -> CompletionClientProvider.getOpenAIClient() .getChatCompletion(completionRequest); - case AZURE -> CompletionClientProvider.getAzureClient() - .getChatCompletion(completionRequest); case OLLAMA -> CompletionClientProvider.getOllamaClient() .getChatCompletion(completionRequest); default -> throw new RuntimeException("Unknown service selected"); @@ -207,10 +202,6 @@ public final class CompletionRequestService { private static boolean isRequestAllowed(ServiceType serviceType) { return switch (serviceType) { case OPENAI -> CredentialsStore.INSTANCE.isCredentialSet(CredentialKey.OpenaiApiKey.INSTANCE); - case AZURE -> CredentialsStore.INSTANCE.isCredentialSet( - AzureSettings.getCurrentState().isUseAzureApiKeyAuthentication() - ? CredentialKey.AzureOpenaiApiKey.INSTANCE - : CredentialKey.AzureActiveDirectoryToken.INSTANCE); case ANTHROPIC -> CredentialsStore.INSTANCE.isCredentialSet( CredentialKey.AnthropicApiKey.INSTANCE ); diff --git a/src/main/java/ee/carlrobert/codegpt/conversations/ConversationService.java b/src/main/java/ee/carlrobert/codegpt/conversations/ConversationService.java index 6fc01ab1..c58cca36 100644 --- a/src/main/java/ee/carlrobert/codegpt/conversations/ConversationService.java +++ b/src/main/java/ee/carlrobert/codegpt/conversations/ConversationService.java @@ -7,7 +7,6 @@ import ee.carlrobert.codegpt.conversations.message.Message; import ee.carlrobert.codegpt.settings.GeneralSettings; import ee.carlrobert.codegpt.settings.service.ServiceType; import ee.carlrobert.codegpt.settings.service.anthropic.AnthropicSettings; -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings; import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTServiceSettings; import ee.carlrobert.codegpt.settings.service.google.GoogleSettings; import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings; @@ -197,7 +196,6 @@ public final class ConversationService { case OPENAI -> OpenAISettings.getCurrentState().getModel(); case CUSTOM_OPENAI -> "CustomService"; case ANTHROPIC -> AnthropicSettings.getCurrentState().getModel(); - case AZURE -> AzureSettings.getCurrentState().getDeploymentId(); case LLAMA_CPP -> { var llamaSettings = LlamaSettings.getCurrentState(); yield llamaSettings.isUseCustomModel() diff --git a/src/main/java/ee/carlrobert/codegpt/settings/GeneralSettings.java b/src/main/java/ee/carlrobert/codegpt/settings/GeneralSettings.java index b818c513..de5f5da8 100644 --- a/src/main/java/ee/carlrobert/codegpt/settings/GeneralSettings.java +++ b/src/main/java/ee/carlrobert/codegpt/settings/GeneralSettings.java @@ -11,7 +11,6 @@ import ee.carlrobert.codegpt.conversations.Conversation; import ee.carlrobert.codegpt.settings.service.ProviderChangeNotifier; import ee.carlrobert.codegpt.settings.service.ServiceType; import ee.carlrobert.codegpt.settings.service.anthropic.AnthropicSettings; -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings; import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTService; import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTServiceSettings; import ee.carlrobert.codegpt.settings.service.google.GoogleSettings; @@ -114,8 +113,6 @@ public class GeneralSettings implements PersistentStateComponent { - - private AzureSettingsState state = new AzureSettingsState(); - - @Override - @NotNull - public AzureSettingsState getState() { - return state; - } - - @Override - public void loadState(@NotNull AzureSettingsState state) { - this.state = state; - } - - public static AzureSettingsState getCurrentState() { - return getInstance().getState(); - } - - public static AzureSettings getInstance() { - return ApplicationManager.getApplication().getService(AzureSettings.class); - } -} diff --git a/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsForm.java b/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsForm.java deleted file mode 100644 index 2e495cc1..00000000 --- a/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsForm.java +++ /dev/null @@ -1,177 +0,0 @@ -package ee.carlrobert.codegpt.settings.service.azure; - -import static ee.carlrobert.codegpt.ui.UIUtil.withEmptyLeftBorder; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.ui.TitledSeparator; -import com.intellij.ui.components.JBPasswordField; -import com.intellij.ui.components.JBRadioButton; -import com.intellij.ui.components.JBTextField; -import com.intellij.util.ui.FormBuilder; -import com.intellij.util.ui.UI; -import ee.carlrobert.codegpt.CodeGPTBundle; -import ee.carlrobert.codegpt.credentials.CredentialsStore; -import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey; -import java.util.List; -import java.util.Map; -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import org.jetbrains.annotations.Nullable; - -public class AzureSettingsForm { - - private final JBRadioButton useAzureApiKeyAuthenticationRadioButton; - private final JBPasswordField azureApiKeyField; - private final JPanel azureApiKeyFieldPanel; - private final JBRadioButton useAzureActiveDirectoryAuthenticationRadioButton; - private final JBPasswordField azureActiveDirectoryTokenField; - private final JPanel azureActiveDirectoryTokenFieldPanel; - private final JBTextField azureResourceNameField; - private final JBTextField azureDeploymentIdField; - private final JBTextField azureApiVersionField; - - public AzureSettingsForm(AzureSettingsState settings) { - useAzureApiKeyAuthenticationRadioButton = new JBRadioButton( - CodeGPTBundle.get("settingsConfigurable.service.azure.useApiKeyAuth.label"), - settings.isUseAzureApiKeyAuthentication()); - useAzureActiveDirectoryAuthenticationRadioButton = new JBRadioButton( - CodeGPTBundle.get("settingsConfigurable.service.azure.useActiveDirectoryAuth.label"), - settings.isUseAzureActiveDirectoryAuthentication()); - azureApiKeyField = new JBPasswordField(); - azureApiKeyField.setColumns(30); - ApplicationManager.getApplication().executeOnPooledThread(() -> { - var apiKey = CredentialsStore.getCredential(CredentialKey.AzureOpenaiApiKey.INSTANCE); - SwingUtilities.invokeLater(() -> azureApiKeyField.setText(apiKey)); - }); - azureApiKeyFieldPanel = UI.PanelFactory.panel(azureApiKeyField) - .withLabel(CodeGPTBundle.get("settingsConfigurable.shared.apiKey.label")) - .resizeX(false) - .createPanel(); - azureActiveDirectoryTokenField = new JBPasswordField(); - azureActiveDirectoryTokenField.setColumns(30); - ApplicationManager.getApplication().executeOnPooledThread(() -> { - var apiKey = CredentialsStore.getCredential(CredentialKey.AzureActiveDirectoryToken.INSTANCE); - SwingUtilities.invokeLater(() -> azureActiveDirectoryTokenField.setText(apiKey)); - }); - azureActiveDirectoryTokenFieldPanel = UI.PanelFactory.panel(azureActiveDirectoryTokenField) - .withLabel(CodeGPTBundle.get("settingsConfigurable.service.azure.bearerToken.label")) - .resizeX(false) - .createPanel(); - azureResourceNameField = new JBTextField(settings.getResourceName(), 35); - azureDeploymentIdField = new JBTextField(settings.getDeploymentId(), 35); - azureApiVersionField = new JBTextField(settings.getApiVersion(), 35); - - registerPanelsVisibility(settings); - registerRadioButtons(); - } - - public JPanel getForm() { - var authPanel = withEmptyLeftBorder(FormBuilder.createFormBuilder() - .addComponent(UI.PanelFactory - .panel(useAzureApiKeyAuthenticationRadioButton) - .resizeX(false) - .createPanel()) - .addComponent(withEmptyLeftBorder(azureApiKeyFieldPanel)) - .addComponent(UI.PanelFactory - .panel(useAzureActiveDirectoryAuthenticationRadioButton) - .resizeX(false) - .createPanel()) - .addComponent(withEmptyLeftBorder(azureActiveDirectoryTokenFieldPanel)) - .getPanel()); - - var configPanel = withEmptyLeftBorder(UI.PanelFactory.grid() - .add(UI.PanelFactory.panel(azureResourceNameField) - .withLabel(CodeGPTBundle.get( - "settingsConfigurable.service.azure.resourceName.label")) - .resizeX(false) - .withComment(CodeGPTBundle.get( - "settingsConfigurable.service.azure.resourceName.comment"))) - .add(UI.PanelFactory.panel(azureDeploymentIdField) - .withLabel(CodeGPTBundle.get( - "settingsConfigurable.service.azure.deploymentId.label")) - .resizeX(false) - .withComment(CodeGPTBundle.get( - "settingsConfigurable.service.azure.deploymentId.comment"))) - .add(UI.PanelFactory.panel(azureApiVersionField) - .withLabel(CodeGPTBundle.get( - "shared.apiVersion")) - .resizeX(false) - .withComment(CodeGPTBundle.get( - "settingsConfigurable.service.azure.apiVersion.comment"))) - .createPanel()); - - return FormBuilder.createFormBuilder() - .addComponent(new TitledSeparator( - CodeGPTBundle.get("settingsConfigurable.shared.authentication.title"))) - .addComponent(authPanel) - .addComponent(new TitledSeparator( - CodeGPTBundle.get("settingsConfigurable.shared.requestConfiguration.title"))) - .addComponent(configPanel) - .addComponentFillVertically(new JPanel(), 0) - .getPanel(); - } - - public AzureSettingsState getCurrentState() { - var state = new AzureSettingsState(); - state.setUseAzureActiveDirectoryAuthentication( - useAzureActiveDirectoryAuthenticationRadioButton.isSelected()); - state.setUseAzureApiKeyAuthentication(useAzureApiKeyAuthenticationRadioButton.isSelected()); - state.setResourceName(azureResourceNameField.getText()); - state.setDeploymentId(azureDeploymentIdField.getText()); - state.setApiVersion(azureApiVersionField.getText()); - return state; - } - - public void resetForm() { - var state = AzureSettings.getCurrentState(); - azureApiKeyField.setText( - CredentialsStore.getCredential(CredentialKey.AzureOpenaiApiKey.INSTANCE) - ); - azureActiveDirectoryTokenField.setText( - CredentialsStore.getCredential(CredentialKey.AzureActiveDirectoryToken.INSTANCE)); - useAzureApiKeyAuthenticationRadioButton.setSelected(state.isUseAzureApiKeyAuthentication()); - useAzureActiveDirectoryAuthenticationRadioButton.setSelected( - state.isUseAzureActiveDirectoryAuthentication()); - azureResourceNameField.setText(state.getResourceName()); - azureDeploymentIdField.setText(state.getDeploymentId()); - azureApiVersionField.setText(state.getApiVersion()); - } - - public @Nullable String getActiveDirectoryToken() { - var activeDirToken = new String(azureActiveDirectoryTokenField.getPassword()); - if (activeDirToken.isEmpty()) { - return null; - } - return activeDirToken; - } - - public @Nullable String getApiKey() { - var apiKey = new String(azureApiKeyField.getPassword()); - return apiKey.isEmpty() ? null : apiKey; - } - - private void registerPanelsVisibility(AzureSettingsState azureSettings) { - azureApiKeyFieldPanel.setVisible(azureSettings.isUseAzureApiKeyAuthentication()); - azureActiveDirectoryTokenFieldPanel.setVisible( - azureSettings.isUseAzureActiveDirectoryAuthentication()); - } - - private void registerRadioButtons() { - registerRadioButtons(List.of( - Map.entry(useAzureApiKeyAuthenticationRadioButton, azureApiKeyFieldPanel), - Map.entry(useAzureActiveDirectoryAuthenticationRadioButton, - azureActiveDirectoryTokenFieldPanel))); - } - - // TODO: Move - private void registerRadioButtons(List> entries) { - var buttonGroup = new ButtonGroup(); - entries.forEach(entry -> buttonGroup.add(entry.getKey())); - entries.forEach(entry -> entry.getKey().addActionListener((e) -> { - for (Map.Entry innerEntry : entries) { - innerEntry.getValue().setVisible(innerEntry.equals(entry)); - } - })); - } -} diff --git a/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsState.java b/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsState.java deleted file mode 100644 index dced9a5f..00000000 --- a/src/main/java/ee/carlrobert/codegpt/settings/service/azure/AzureSettingsState.java +++ /dev/null @@ -1,75 +0,0 @@ -package ee.carlrobert.codegpt.settings.service.azure; - -import java.util.Objects; - -public class AzureSettingsState { - - private String resourceName = ""; - private String deploymentId = ""; - private String apiVersion = ""; - private boolean useAzureApiKeyAuthentication = true; - private boolean useAzureActiveDirectoryAuthentication; - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getDeploymentId() { - return deploymentId; - } - - public void setDeploymentId(String deploymentId) { - this.deploymentId = deploymentId; - } - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public boolean isUseAzureApiKeyAuthentication() { - return useAzureApiKeyAuthentication; - } - - public void setUseAzureApiKeyAuthentication(boolean useAzureApiKeyAuthentication) { - this.useAzureApiKeyAuthentication = useAzureApiKeyAuthentication; - } - - public boolean isUseAzureActiveDirectoryAuthentication() { - return useAzureActiveDirectoryAuthentication; - } - - public void setUseAzureActiveDirectoryAuthentication( - boolean useAzureActiveDirectoryAuthentication) { - this.useAzureActiveDirectoryAuthentication = useAzureActiveDirectoryAuthentication; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AzureSettingsState that = (AzureSettingsState) o; - return useAzureApiKeyAuthentication == that.useAzureApiKeyAuthentication - && useAzureActiveDirectoryAuthentication == that.useAzureActiveDirectoryAuthentication - && Objects.equals(resourceName, that.resourceName) - && Objects.equals(deploymentId, that.deploymentId) - && Objects.equals(apiVersion, that.apiVersion); - } - - @Override - public int hashCode() { - return Objects.hash(resourceName, deploymentId, apiVersion, useAzureApiKeyAuthentication, - useAzureActiveDirectoryAuthentication); - } -} diff --git a/src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ui/textarea/ModelComboBoxAction.java b/src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ui/textarea/ModelComboBoxAction.java index ee7c1934..b6b09d4a 100644 --- a/src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ui/textarea/ModelComboBoxAction.java +++ b/src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ui/textarea/ModelComboBoxAction.java @@ -1,7 +1,6 @@ package ee.carlrobert.codegpt.toolwindow.chat.ui.textarea; import static ee.carlrobert.codegpt.settings.service.ServiceType.ANTHROPIC; -import static ee.carlrobert.codegpt.settings.service.ServiceType.AZURE; import static ee.carlrobert.codegpt.settings.service.ServiceType.CODEGPT; import static ee.carlrobert.codegpt.settings.service.ServiceType.CUSTOM_OPENAI; import static ee.carlrobert.codegpt.settings.service.ServiceType.GOOGLE; @@ -174,10 +173,6 @@ public class ModelComboBoxAction extends ComboBoxAction { Icons.Anthropic, presentation)); } - if (availableProviders.contains(AZURE)) { - actionGroup.add( - createModelAction(AZURE, "Azure OpenAI", Icons.Azure, presentation)); - } if (availableProviders.contains(GOOGLE)) { var googleGroup = DefaultActionGroup.createPopupGroup(() -> "Google (Gemini)"); googleGroup.getTemplatePresentation().setIcon(Icons.Google); @@ -260,10 +255,6 @@ public class ModelComboBoxAction extends ComboBoxAction { templatePresentation.setIcon(Icons.Anthropic); templatePresentation.setText("Anthropic (Claude)"); break; - case AZURE: - templatePresentation.setIcon(Icons.Azure); - templatePresentation.setText("Azure OpenAI"); - break; case LLAMA_CPP: templatePresentation.setText(getLlamaCppPresentationText()); templatePresentation.setIcon(Icons.Llama); diff --git a/src/main/java/ee/carlrobert/codegpt/ui/ModelIconLabel.java b/src/main/java/ee/carlrobert/codegpt/ui/ModelIconLabel.java index f125a5b1..49da1db1 100644 --- a/src/main/java/ee/carlrobert/codegpt/ui/ModelIconLabel.java +++ b/src/main/java/ee/carlrobert/codegpt/ui/ModelIconLabel.java @@ -10,20 +10,12 @@ import javax.swing.SwingConstants; public class ModelIconLabel extends JBLabel { public ModelIconLabel(String clientCode, String modelCode) { - if ("you.chat.completion".equals(clientCode)) { - setIcon(Icons.You); - return; - } - if ("chat.completion".equals(clientCode)) { setIcon(Icons.OpenAI); } if ("anthropic.chat.completion".equals(clientCode)) { setIcon(Icons.Anthropic); } - if ("azure.chat.completion".equals(clientCode)) { - setIcon(Icons.Azure); - } if ("llama.chat.completion".equals(clientCode)) { setIcon(Icons.Llama); } diff --git a/src/main/kotlin/ee/carlrobert/codegpt/actions/CodeCompletionFeatureToggleActions.kt b/src/main/kotlin/ee/carlrobert/codegpt/actions/CodeCompletionFeatureToggleActions.kt index dddb98de..03470804 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/actions/CodeCompletionFeatureToggleActions.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/actions/CodeCompletionFeatureToggleActions.kt @@ -29,7 +29,6 @@ abstract class CodeCompletionFeatureToggleActions( CUSTOM_OPENAI -> service().state.active.codeCompletionSettings::codeCompletionsEnabled::set ANTHROPIC, - AZURE, GOOGLE, null -> { _: Boolean -> Unit } // no-op for these services }(enableFeatureAction) @@ -48,7 +47,6 @@ abstract class CodeCompletionFeatureToggleActions( OLLAMA -> true ANTHROPIC, - AZURE, GOOGLE, null -> false } diff --git a/src/main/kotlin/ee/carlrobert/codegpt/codecompletions/DebouncedCodeCompletionProvider.kt b/src/main/kotlin/ee/carlrobert/codegpt/codecompletions/DebouncedCodeCompletionProvider.kt index bd59d9a9..67cee019 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/codecompletions/DebouncedCodeCompletionProvider.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/codecompletions/DebouncedCodeCompletionProvider.kt @@ -111,7 +111,6 @@ class DebouncedCodeCompletionProvider : DebouncedInlineCompletionProvider() { ServiceType.LLAMA_CPP -> LlamaSettings.isCodeCompletionsPossible() ServiceType.OLLAMA -> service().state.codeCompletionsEnabled ServiceType.ANTHROPIC, - ServiceType.AZURE, ServiceType.GOOGLE, null -> false } diff --git a/src/main/kotlin/ee/carlrobert/codegpt/completions/CompletionRequestFactory.kt b/src/main/kotlin/ee/carlrobert/codegpt/completions/CompletionRequestFactory.kt index d760f091..cc215b84 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/completions/CompletionRequestFactory.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/completions/CompletionRequestFactory.kt @@ -23,7 +23,6 @@ interface CompletionRequestFactory { ServiceType.CODEGPT -> CodeGPTRequestFactory(ClassStructureSerializer) ServiceType.OPENAI -> OpenAIRequestFactory() ServiceType.CUSTOM_OPENAI -> CustomOpenAIRequestFactory() - ServiceType.AZURE -> AzureRequestFactory() ServiceType.ANTHROPIC -> ClaudeRequestFactory() ServiceType.GOOGLE -> GoogleRequestFactory() ServiceType.OLLAMA -> OllamaRequestFactory() diff --git a/src/main/kotlin/ee/carlrobert/codegpt/completions/factory/AzureRequestFactory.kt b/src/main/kotlin/ee/carlrobert/codegpt/completions/factory/AzureRequestFactory.kt deleted file mode 100644 index 1541d4f4..00000000 --- a/src/main/kotlin/ee/carlrobert/codegpt/completions/factory/AzureRequestFactory.kt +++ /dev/null @@ -1,35 +0,0 @@ -package ee.carlrobert.codegpt.completions.factory - -import com.intellij.openapi.components.service -import ee.carlrobert.codegpt.completions.BaseRequestFactory -import ee.carlrobert.codegpt.completions.ChatCompletionParameters -import ee.carlrobert.codegpt.completions.factory.OpenAIRequestFactory.Companion.buildOpenAIMessages -import ee.carlrobert.codegpt.settings.configuration.ConfigurationSettings -import ee.carlrobert.llm.client.openai.completion.request.OpenAIChatCompletionRequest -import ee.carlrobert.llm.completion.CompletionRequest - -class AzureRequestFactory : BaseRequestFactory() { - - override fun createChatRequest(params: ChatCompletionParameters): OpenAIChatCompletionRequest { - val configuration = service().state - val requestBuilder: OpenAIChatCompletionRequest.Builder = - OpenAIChatCompletionRequest.Builder(buildOpenAIMessages(null, params)) - .setMaxTokens(configuration.maxTokens) - .setStream(true) - .setTemperature(configuration.temperature.toDouble()) - return requestBuilder.build() - } - - override fun createBasicCompletionRequest( - systemPrompt: String, - userPrompt: String, - maxTokens: Int, - stream: Boolean - ): CompletionRequest { - return OpenAIRequestFactory.createBasicCompletionRequest( - systemPrompt, - userPrompt, - isStream = stream - ) - } -} diff --git a/src/main/kotlin/ee/carlrobert/codegpt/credentials/CredentialsStore.kt b/src/main/kotlin/ee/carlrobert/codegpt/credentials/CredentialsStore.kt index 5c75dcd6..b99365c5 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/credentials/CredentialsStore.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/credentials/CredentialsStore.kt @@ -61,14 +61,6 @@ object CredentialsStore { override val value: String = "ANTHROPIC_API_KEY" } - data object AzureOpenaiApiKey : CredentialKey() { - override val value: String = "AZURE_OPENAI_API_KEY" - } - - data object AzureActiveDirectoryToken : CredentialKey() { - override val value: String = "AZURE_ACTIVE_DIRECTORY_TOKEN" - } - data object LlamaApiKey : CredentialKey() { override val value: String = "LLAMA_API_KEY" } diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/AzureServiceConfigurable.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/AzureServiceConfigurable.kt deleted file mode 100644 index aebde2f9..00000000 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/AzureServiceConfigurable.kt +++ /dev/null @@ -1,43 +0,0 @@ -package ee.carlrobert.codegpt.settings.service - -import com.intellij.openapi.components.service -import com.intellij.openapi.options.Configurable -import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey.AzureActiveDirectoryToken -import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey.AzureOpenaiApiKey -import ee.carlrobert.codegpt.credentials.CredentialsStore.getCredential -import ee.carlrobert.codegpt.credentials.CredentialsStore.setCredential -import ee.carlrobert.codegpt.settings.GeneralSettings -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings -import ee.carlrobert.codegpt.settings.service.azure.AzureSettingsForm -import javax.swing.JComponent - -class AzureServiceConfigurable : Configurable { - - private lateinit var component: AzureSettingsForm - - override fun getDisplayName(): String { - return "ProxyAI: Azure Service" - } - - override fun createComponent(): JComponent { - component = AzureSettingsForm(service().state) - return component.getForm() - } - - override fun isModified(): Boolean { - return component.getCurrentState() != service().state - || component.getActiveDirectoryToken() != getCredential(AzureActiveDirectoryToken) - || component.getApiKey() != getCredential(AzureOpenaiApiKey) - } - - override fun apply() { - service().state.selectedService = ServiceType.AZURE - service().loadState(component.currentState) - setCredential(AzureOpenaiApiKey, component.getApiKey()) - setCredential(AzureActiveDirectoryToken, component.getActiveDirectoryToken()) - } - - override fun reset() { - component.resetForm() - } -} \ No newline at end of file diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/ServiceConfigurableComponent.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/ServiceConfigurableComponent.kt index 94534f3d..08249e9b 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/ServiceConfigurableComponent.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/ServiceConfigurableComponent.kt @@ -55,7 +55,6 @@ class ServiceConfigurableComponent { "ProxyAI" to CodeGPTServiceConfigurable::class.java, "OpenAI" to OpenAIServiceConfigurable::class.java, "Custom OpenAI" to CustomServiceConfigurable::class.java, - "Azure" to AzureServiceConfigurable::class.java, "Anthropic" to AnthropicServiceConfigurable::class.java, "Google" to GoogleSettingsConfigurable::class.java, "LLaMA C/C++ (Local)" to LlamaServiceConfigurable::class.java, diff --git a/src/main/kotlin/ee/carlrobert/codegpt/ui/textarea/UserInputPanel.kt b/src/main/kotlin/ee/carlrobert/codegpt/ui/textarea/UserInputPanel.kt index 3b0c551d..0f0d2283 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/ui/textarea/UserInputPanel.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/ui/textarea/UserInputPanel.kt @@ -278,7 +278,6 @@ class UserInputPanel( ServiceType.CUSTOM_OPENAI, ServiceType.ANTHROPIC, ServiceType.GOOGLE, - ServiceType.AZURE, ServiceType.OLLAMA -> true ServiceType.CODEGPT -> { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 5601570f..b2515b0b 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -38,8 +38,6 @@ instance="ee.carlrobert.codegpt.settings.service.OpenAIServiceConfigurable"/> - - diff --git a/src/main/resources/icons/azure.svg b/src/main/resources/icons/azure.svg deleted file mode 100644 index b7123025..00000000 --- a/src/main/resources/icons/azure.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/resources/icons/you.svg b/src/main/resources/icons/you.svg deleted file mode 100644 index d4d48352..00000000 --- a/src/main/resources/icons/you.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/src/main/resources/icons/you_dark.svg b/src/main/resources/icons/you_dark.svg deleted file mode 100644 index 7b017a39..00000000 --- a/src/main/resources/icons/you_dark.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/icons/you_small.png b/src/main/resources/icons/you_small.png deleted file mode 100644 index 08ed4f31..00000000 Binary files a/src/main/resources/icons/you_small.png and /dev/null differ diff --git a/src/main/resources/messages/codegpt.properties b/src/main/resources/messages/codegpt.properties index a60dc34d..6a058c77 100644 --- a/src/main/resources/messages/codegpt.properties +++ b/src/main/resources/messages/codegpt.properties @@ -60,22 +60,6 @@ settingsConfigurable.service.google.model.comment=Note: Gemini Vision models User settings. settingsConfigurable.service.anthropic.apiVersion.comment=We always recommend using the latest API version whenever possible. settingsConfigurable.service.anthropic.model.comment=For details on model comparison metrics, see model comparison. -settingsConfigurable.service.azure.resourceName.label=Resource name: -settingsConfigurable.service.azure.resourceName.comment=The name of your Azure OpenAI resource. -settingsConfigurable.service.azure.deploymentId.label=Deployment ID: -settingsConfigurable.service.azure.deploymentId.comment=The name of your model deployment. You're required to first deploy a model before you can make calls. -settingsConfigurable.service.azure.apiVersion.comment=The API version to use for this operation. This follows the YYYY-MM-DD format. -settingsConfigurable.service.azure.bearerToken.label=Bearer token: -settingsConfigurable.service.azure.useApiKeyAuth.label=Use API key authentication -settingsConfigurable.service.azure.useActiveDirectoryAuth.label=Use Active Directory authentication -settingsConfigurable.service.you.email.label=Email address: -settingsConfigurable.service.you.password.label=Password: -settingsConfigurable.service.you.signIn.label=Sign In -settingsConfigurable.service.you.signOut.label=Sign Out -settingsConfigurable.service.you.displayResults.label=Display web search results -settingsConfigurable.service.you.authentication.title=Authentication (Optional) -settingsConfigurable.service.you.userInformation.title=User Information -settingsConfigurable.service.you.chatPreferences.title=Chat Preferences settingsConfigurable.service.llama.modelPreferences.title=Model Preferences settingsConfigurable.service.llama.serverPreferences.title=Server Preferences settingsConfigurable.service.llama.modelSize.label=Model size: diff --git a/src/test/kotlin/ee/carlrobert/codegpt/completions/DefaultToolwindowChatCompletionRequestHandlerTest.kt b/src/test/kotlin/ee/carlrobert/codegpt/completions/DefaultToolwindowChatCompletionRequestHandlerTest.kt index 3d7464b5..7a8462f7 100644 --- a/src/test/kotlin/ee/carlrobert/codegpt/completions/DefaultToolwindowChatCompletionRequestHandlerTest.kt +++ b/src/test/kotlin/ee/carlrobert/codegpt/completions/DefaultToolwindowChatCompletionRequestHandlerTest.kt @@ -56,52 +56,6 @@ class DefaultToolwindowChatCompletionRequestHandlerTest : IntegrationTest() { waitExpecting { "Hello!" == message.response } } - fun testAzureChatCompletionCall() { - useAzureService() - service().state.personas.selectedPersona.instructions = - "TEST_SYSTEM_PROMPT" - val conversationService = ConversationService.getInstance() - val prevMessage = Message("TEST_PREV_PROMPT") - prevMessage.response = "TEST_PREV_RESPONSE" - val conversation = conversationService.startConversation() - conversation.addMessage(prevMessage) - conversationService.saveConversation(conversation) - expectAzure(StreamHttpExchange { request: RequestEntity -> - assertThat(request.uri.path).isEqualTo( - "/openai/deployments/TEST_DEPLOYMENT_ID/chat/completions" - ) - assertThat(request.uri.query).isEqualTo("api-version=TEST_API_VERSION") - assertThat(request.headers["Api-key"]!![0]).isEqualTo("TEST_API_KEY") - assertThat(request.headers["X-llm-application-tag"]!![0]).isEqualTo("codegpt") - assertThat(request.body) - .extracting("messages") - .isEqualTo( - listOf( - mapOf("role" to "system", "content" to "TEST_SYSTEM_PROMPT"), - mapOf("role" to "user", "content" to "TEST_PREV_PROMPT"), - mapOf("role" to "assistant", "content" to "TEST_PREV_RESPONSE"), - mapOf("role" to "user", "content" to "TEST_PROMPT") - ) - ) - listOf( - jsonMapResponse( - "choices", - jsonArray(jsonMap("delta", jsonMap("role", "assistant"))) - ), - jsonMapResponse("choices", jsonArray(jsonMap("delta", jsonMap("content", "Hel")))), - jsonMapResponse("choices", jsonArray(jsonMap("delta", jsonMap("content", "lo")))), - jsonMapResponse("choices", jsonArray(jsonMap("delta", jsonMap("content", "!")))) - ) - }) - val message = Message("TEST_PROMPT") - val requestHandler = - ToolwindowChatCompletionRequestHandler(project, getRequestEventListener(message)) - - requestHandler.call(ChatCompletionParameters.builder(conversation, message).build()) - - waitExpecting { "Hello!" == message.response } - } - fun testLlamaChatCompletionCall() { useLlamaService() service().state.maxTokens = 99 diff --git a/src/test/kotlin/ee/carlrobert/codegpt/settings/state/GeneralSettingsTest.kt b/src/test/kotlin/ee/carlrobert/codegpt/settings/state/GeneralSettingsTest.kt index 649fe265..ab3271ce 100644 --- a/src/test/kotlin/ee/carlrobert/codegpt/settings/state/GeneralSettingsTest.kt +++ b/src/test/kotlin/ee/carlrobert/codegpt/settings/state/GeneralSettingsTest.kt @@ -36,17 +36,6 @@ class GeneralSettingsTest : BasePlatformTestCase() { assertThat(settings.state.selectedService).isEqualTo(ServiceType.CUSTOM_OPENAI) } - fun testAzureSettingsSync() { - val settings = GeneralSettings.getInstance() - val conversation = Conversation() - conversation.model = "gpt-4" - conversation.clientCode = "azure.chat.completion" - - settings.sync(conversation) - - assertThat(settings.state.selectedService).isEqualTo(ServiceType.AZURE) - } - fun testLlamaSettingsModelPathSync() { val llamaSettings = LlamaSettings.getCurrentState() llamaSettings.huggingFaceModel = HuggingFaceModel.WIZARD_CODER_PYTHON_7B_Q3 diff --git a/src/test/kotlin/testsupport/mixin/ShortcutsTestMixin.kt b/src/test/kotlin/testsupport/mixin/ShortcutsTestMixin.kt index c1c6f2a4..5df5f639 100644 --- a/src/test/kotlin/testsupport/mixin/ShortcutsTestMixin.kt +++ b/src/test/kotlin/testsupport/mixin/ShortcutsTestMixin.kt @@ -7,7 +7,6 @@ import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey.* import ee.carlrobert.codegpt.credentials.CredentialsStore.setCredential import ee.carlrobert.codegpt.settings.GeneralSettings import ee.carlrobert.codegpt.settings.service.ServiceType -import ee.carlrobert.codegpt.settings.service.azure.AzureSettings import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTServiceSettings import ee.carlrobert.codegpt.settings.service.google.GoogleSettings import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings @@ -37,15 +36,6 @@ interface ShortcutsTestMixin { } } - fun useAzureService() { - GeneralSettings.getCurrentState().selectedService = ServiceType.AZURE - setCredential(AzureOpenaiApiKey, "TEST_API_KEY") - val azureSettings = AzureSettings.getCurrentState() - azureSettings.resourceName = "TEST_RESOURCE_NAME" - azureSettings.apiVersion = "TEST_API_VERSION" - azureSettings.deploymentId = "TEST_DEPLOYMENT_ID" - } - fun useLlamaService(codeCompletionsEnabled: Boolean = false) { GeneralSettings.getCurrentState().selectedService = ServiceType.LLAMA_CPP LlamaSettings.getCurrentState().serverPort = null