From 2b7266459c667981571925ec61fc4f9cc72d2737 Mon Sep 17 00:00:00 2001 From: Luo Tim Date: Mon, 11 Dec 2023 18:32:18 +0800 Subject: [PATCH] Fix settings opening --- .../devchat/handler/ShowSettingDialogRequestHandler.kt | 10 +--------- .../devchat/idea/settings/DevChatSettingsComponent.kt | 8 ++++---- .../kotlin/ai/devchat/idea/settings/SupportedModels.kt | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/ai/devchat/devchat/handler/ShowSettingDialogRequestHandler.kt b/src/main/kotlin/ai/devchat/devchat/handler/ShowSettingDialogRequestHandler.kt index fdd2cc1..a074d73 100644 --- a/src/main/kotlin/ai/devchat/devchat/handler/ShowSettingDialogRequestHandler.kt +++ b/src/main/kotlin/ai/devchat/devchat/handler/ShowSettingDialogRequestHandler.kt @@ -2,21 +2,13 @@ package ai.devchat.devchat.handler import ai.devchat.devchat.BaseActionHandler import ai.devchat.devchat.DevChatActions -import ai.devchat.idea.settings.DevChatSettingsConfigurable import com.alibaba.fastjson.JSONObject -import com.intellij.openapi.actionSystem.* -import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.options.ShowSettingsUtil class ShowSettingDialogRequestHandler(metadata: JSONObject?, payload: JSONObject?) : BaseActionHandler(metadata, payload) { override val actionName: String = DevChatActions.SHOW_SETTING_DIALOG_REQUEST override fun action() { - val project = handler?.project - val dataContext = DataContext { dataId -> project.takeIf { CommonDataKeys.PROJECT.name == dataId }} - val settingsAction = ActionManager.getInstance().getAction("ShowSettings") - val event = AnActionEvent.createFromDataContext(ActionPlaces.POPUP, null, dataContext) - ApplicationManager.getApplication().invokeLater { settingsAction.actionPerformed(event) } - ShowSettingsUtil.getInstance().editConfigurable(project, DevChatSettingsConfigurable.get()) + ShowSettingsUtil.getInstance().showSettingsDialog(handler?.project, "DevChat") } } diff --git a/src/main/kotlin/ai/devchat/idea/settings/DevChatSettingsComponent.kt b/src/main/kotlin/ai/devchat/idea/settings/DevChatSettingsComponent.kt index c7045c0..5f2f3b8 100644 --- a/src/main/kotlin/ai/devchat/idea/settings/DevChatSettingsComponent.kt +++ b/src/main/kotlin/ai/devchat/idea/settings/DevChatSettingsComponent.kt @@ -19,10 +19,10 @@ class DevChatSettingsComponent { init { panel = FormBuilder.createFormBuilder() - .addLabeledComponent(JBLabel("api_base"), apiBaseText, 1, false) - .addLabeledComponent(JBLabel("api_key"), apiKeyText, 2, false) - .addLabeledComponent(JBLabel("max_log_count"), maxLogCountText, 3, false) - .addLabeledComponent(JBLabel("default_model"), defaultModelText, 4, false) + .addLabeledComponent(JBLabel("API base"), apiBaseText, 1, false) + .addLabeledComponent(JBLabel("API key"), apiKeyText, 2, false) + .addLabeledComponent(JBLabel("Max log count"), maxLogCountText, 3, false) + .addLabeledComponent(JBLabel("Default model"), defaultModelText, 4, false) .addComponentFillVertically(JPanel(), 0) .panel defaultModelText.selectedItem = "gpt-3.5-turbo" diff --git a/src/main/kotlin/ai/devchat/idea/settings/SupportedModels.kt b/src/main/kotlin/ai/devchat/idea/settings/SupportedModels.kt index 497ed6b..4b493e1 100644 --- a/src/main/kotlin/ai/devchat/idea/settings/SupportedModels.kt +++ b/src/main/kotlin/ai/devchat/idea/settings/SupportedModels.kt @@ -1,9 +1,9 @@ package ai.devchat.idea.settings val supportedModels = setOf( - "gpt-3.5", + "gpt-3.5-turbo", // "gpt-3.5-turbo-1106", - "gpt-3.5-16k", + "gpt-3.5-turbo-16k", "gpt-4", // "gpt-4-1106-preview", "claude-2",