@@ -14,6 +14,7 @@ import com.intellij.openapi.ui.naturalSorted
1414import com.intellij.ui.CommonActionsPanel
1515import com.intellij.ui.ToolbarDecorator
1616import com.intellij.ui.components.JBLabel
17+ import com.intellij.ui.components.JBTextField
1718import com.intellij.ui.dsl.builder.*
1819import com.intellij.ui.util.minimumWidth
1920import kotlinx.coroutines.*
@@ -23,21 +24,44 @@ import javax.swing.JPasswordField
2324
2425class AppSettingsConfigurable : BoundConfigurable (message("settings.general.group.title")) {
2526
27+ private val hostComboBox = ComboBox <String >()
2628 private val tokenPasswordField = JPasswordField ()
2729 private val verifyLabel = JBLabel ()
28- private var modelComboBox: ComboBox <String > = ComboBox <String >()
30+ private val proxyTextField = JBTextField ()
31+ private var modelComboBox = ComboBox <String >()
2932 private val promptTable = PromptTable ()
3033 private lateinit var toolbarDecorator: ToolbarDecorator
3134 private lateinit var promptComboBox: Cell <ComboBox <Prompt >>
3235
3336 init {
37+ hostComboBox.isEditable = true
38+ hostComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.openAIHosts.naturalSorted()))
3439 modelComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.openAIModelIds.naturalSorted()))
3540 modelComboBox.renderer = AppSettingsListCellRenderer ()
3641 }
3742
3843 override fun createPanel () = panel {
3944
4045 group(JBLabel (" OpenAI" )) {
46+ row {
47+ label(message(" settings.openAIHost" ))
48+ .widthGroup(" label" )
49+
50+ cell(hostComboBox)
51+ .bindItem(AppSettings .instance::openAIHost.toNullableProperty())
52+ .widthGroup(" input" )
53+ }
54+ row {
55+ label(message(" settings.openAIProxy" )).widthGroup(" label" )
56+ cell(proxyTextField)
57+ .bindText(AppSettings .instance::proxyUrl.toNonNullableProperty(" " ))
58+ .applyToComponent { minimumWidth = 400 }
59+ .resizableColumn()
60+ .widthGroup(" input" )
61+ }
62+ row {
63+ comment(message(" settings.openAIProxyComment" ))
64+ }
4165 row {
4266 label(message(" settings.openAIToken" ))
4367 .widthGroup(" label" )
@@ -82,16 +106,6 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
82106 .align(AlignX .RIGHT )
83107 .widthGroup(" button" )
84108 }
85- row {
86- label(message(" settings.openAIProxy" )).widthGroup(" label" )
87- textField()
88- .bindText(AppSettings .instance::proxyUrl.toNonNullableProperty(" " ))
89- .applyToComponent { minimumWidth = 350 }
90- .resizableColumn()
91- }
92- row {
93- comment(message(" settings.openAIProxyComment" ))
94- }
95109 }
96110
97111 group(JBLabel (" Prompt" )) {
@@ -156,6 +170,7 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
156170 }
157171
158172 override fun apply () {
173+ AppSettings .instance.openAIHosts.add(hostComboBox.item)
159174 promptTable.apply ()
160175 super .apply ()
161176 }
@@ -177,7 +192,7 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
177192
178193 GlobalScope .launch(Dispatchers .IO ) {
179194 try {
180- OpenAIService .instance.verifyToken( String (tokenPasswordField.password))
195+ OpenAIService .instance.verifyOpenAIConfiguration(hostComboBox.item, String (tokenPasswordField.password), proxyTextField.text )
181196 verifyLabel.text = message(" settings.verify.valid" )
182197 verifyLabel.icon = AllIcons .General .InspectionsOK
183198 } catch (e: OpenAIAPIException ) {
0 commit comments