@@ -35,8 +35,8 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
3535
3636 init {
3737 hostComboBox.isEditable = true
38- hostComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.openAIHosts .naturalSorted()))
39- modelComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.openAIModelIds .naturalSorted()))
38+ hostComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.currentLlmProvider.hosts .naturalSorted()))
39+ modelComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.currentLlmProvider.modelIds .naturalSorted()))
4040 modelComboBox.renderer = AppSettingsListCellRenderer ()
4141 }
4242
@@ -45,150 +45,150 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
4545 group(JBLabel (" OpenAI" )) {
4646 row {
4747 label(message(" settings.openAIHost" ))
48- .widthGroup(" label" )
48+ .widthGroup(" label" )
4949
5050 cell(hostComboBox)
51- .bindItem(AppSettings .instance::openAIHost .toNullableProperty())
52- .widthGroup(" input" )
51+ .bindItem(AppSettings .instance.currentLlmProvider::host .toNullableProperty())
52+ .widthGroup(" input" )
5353 }
5454 row {
5555 label(message(" settings.openAIProxy" )).widthGroup(" label" )
5656 cell(proxyTextField)
57- .bindText(AppSettings .instance::proxyUrl.toNonNullableProperty(" " ))
58- .applyToComponent { minimumWidth = 400 }
59- .resizableColumn()
60- .widthGroup(" input" )
57+ .bindText(AppSettings .instance.currentLlmProvider ::proxyUrl.toNonNullableProperty(" " ))
58+ .applyToComponent { minimumWidth = 400 }
59+ .resizableColumn()
60+ .widthGroup(" input" )
6161 }
6262 row {
6363 comment(message(" settings.openAIProxyComment" ))
6464 }
6565 row {
6666 label(message(" settings.openAISocketTimeout" )).widthGroup(" label" )
6767 cell(socketTimeoutTextField)
68- .bindIntText(AppSettings .instance::openAISocketTimeout )
68+ .bindIntText(AppSettings .instance.currentLlmProvider::timeout )
6969 .applyToComponent { minimumWidth = 400 }
7070 .resizableColumn()
7171 .widthGroup(" input" )
7272 .validationOnInput { isInt(it.text) }
7373 }
7474 row {
7575 label(message(" settings.openAIToken" ))
76- .widthGroup(" label" )
76+ .widthGroup(" label" )
7777 cell(tokenPasswordField)
78- .bindText(
79- { AppSettings .instance.getOpenAIToken() .orEmpty() },
80- { AppSettings .instance.saveOpenAIToken(it) }
81- )
82- .emptyText(message(" settings.openAITokenExample" ))
83- .align(Align .FILL )
84- .resizableColumn()
85- .focused()
78+ .bindText(
79+ { AppSettings .instance.currentLlmProvider.token .orEmpty() },
80+ { AppSettings .instance.currentLlmProvider.token = it }
81+ )
82+ .emptyText(message(" settings.openAITokenExample" ))
83+ .align(Align .FILL )
84+ .resizableColumn()
85+ .focused()
8686 button(message(" settings.verifyToken" )) { verifyToken() }
87- .align(AlignX .RIGHT )
88- .widthGroup(" button" )
87+ .align(AlignX .RIGHT )
88+ .widthGroup(" button" )
8989 }
9090 row {
9191 comment(message(" settings.openAITokenComment" ))
92- .align(AlignX .LEFT )
92+ .align(AlignX .LEFT )
9393 cell(verifyLabel)
94- .align(AlignX .RIGHT )
94+ .align(AlignX .RIGHT )
9595 }
9696 row {
9797 label(message(" settings.openAIModel" )).widthGroup(" label" )
9898
9999 cell(modelComboBox)
100- .bindItem({ AppSettings .instance.openAIModelId }, {
101- if (it != null ) {
102- AppSettings .instance.openAIModelId = it
103- }
104- })
105- .resizableColumn()
106- .align(Align .FILL )
100+ .bindItem({ AppSettings .instance.currentLlmProvider.modelId }, {
101+ if (it != null ) {
102+ AppSettings .instance.currentLlmProvider.modelId = it
103+ }
104+ })
105+ .resizableColumn()
106+ .align(Align .FILL )
107107 button(message(" settings.refreshModels" )) {
108108 runBackgroundableTask(message(" settings.loadingModels" )) {
109109 runBlocking(Dispatchers .IO ) {
110110 OpenAIService .instance.refreshOpenAIModelIds()
111- modelComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.openAIModelIds .naturalSorted()))
112- modelComboBox.item = AppSettings .instance.openAIModelId
111+ modelComboBox.model = DefaultComboBoxModel (Vector (AppSettings .instance.currentLlmProvider.modelIds .naturalSorted()))
112+ modelComboBox.item = AppSettings .instance.currentLlmProvider.modelId
113113 }
114114 }
115115 }
116- .align(AlignX .RIGHT )
117- .widthGroup(" button" )
116+ .align(AlignX .RIGHT )
117+ .widthGroup(" button" )
118118 }
119119
120120 row {
121121 label(message(" settings.openAITemperature" ))
122- .widthGroup(" label" )
122+ .widthGroup(" label" )
123123
124124 textField()
125- .bindText(AppSettings .instance::openAITemperature )
126- .applyToComponent { minimumWidth = 400 }
127- .resizableColumn()
128- .widthGroup(" input" )
129- .validationOnInput { temperatureValid(it.text) }
125+ .bindText(AppSettings .instance.currentLlmProvider::temperature )
126+ .applyToComponent { minimumWidth = 400 }
127+ .resizableColumn()
128+ .widthGroup(" input" )
129+ .validationOnInput { temperatureValid(it.text) }
130130
131131 contextHelp(message(" settings.openAITemperatureComment" ))
132132 }
133133
134134 row {
135135 cell(verifyLabel)
136- .align(AlignX .RIGHT )
136+ .align(AlignX .RIGHT )
137137 }
138138 }
139139
140140 group(JBLabel (" Prompt" )) {
141141 row {
142142 label(message(" settings.locale" )).widthGroup(" labelPrompt" )
143143 comboBox(Locale .getAvailableLocales()
144- .distinctBy { it.displayLanguage }
145- .sortedBy { it.displayLanguage },
146- AppSettingsListCellRenderer ()
144+ .distinctBy { it.displayLanguage }
145+ .sortedBy { it.displayLanguage },
146+ AppSettingsListCellRenderer ()
147147 )
148- .bindItem(AppSettings .instance::locale.toNullableProperty())
148+ .bindItem(AppSettings .instance::locale.toNullableProperty())
149149 browserLink(message(" settings.more-prompts" ), AICommitsBundle .URL_PROMPTS_DISCUSSION .toString())
150- .align(AlignX .RIGHT )
150+ .align(AlignX .RIGHT )
151151 }
152152 row {
153153 label(message(" settings.prompt" )).widthGroup(" labelPrompt" )
154154 promptComboBox = comboBox(AppSettings .instance.prompts.values, AppSettingsListCellRenderer ())
155- .bindItem(AppSettings .instance::currentPrompt.toNullableProperty())
155+ .bindItem(AppSettings .instance::currentPrompt.toNullableProperty())
156156 }
157157 row {
158158 toolbarDecorator = ToolbarDecorator .createDecorator(promptTable.table)
159- .setAddAction {
160- promptTable.addPrompt().let {
161- promptComboBox.component.addItem(it)
162- }
163- }
164- .setEditAction {
165- promptTable.editPrompt()?.let {
166- val editingSelected = promptComboBox.component.selectedItem == it.first
167- promptComboBox.component.removeItem(it.first)
168- promptComboBox.component.addItem(it.second)
169-
170- if (editingSelected) {
171- promptComboBox.component.selectedItem = it.second
172- }
173- }
174- }
175- .setEditActionUpdater {
176- updateActionAvailability(CommonActionsPanel .Buttons .EDIT )
177- true
159+ .setAddAction {
160+ promptTable.addPrompt().let {
161+ promptComboBox.component.addItem(it)
178162 }
179- .setRemoveAction {
180- promptTable.removePrompt()?.let {
181- promptComboBox.component.removeItem(it)
163+ }
164+ .setEditAction {
165+ promptTable.editPrompt()?.let {
166+ val editingSelected = promptComboBox.component.selectedItem == it.first
167+ promptComboBox.component.removeItem(it.first)
168+ promptComboBox.component.addItem(it.second)
169+
170+ if (editingSelected) {
171+ promptComboBox.component.selectedItem = it.second
182172 }
183173 }
184- .setRemoveActionUpdater {
185- updateActionAvailability(CommonActionsPanel .Buttons .REMOVE )
186- true
174+ }
175+ .setEditActionUpdater {
176+ updateActionAvailability(CommonActionsPanel .Buttons .EDIT )
177+ true
178+ }
179+ .setRemoveAction {
180+ promptTable.removePrompt()?.let {
181+ promptComboBox.component.removeItem(it)
187182 }
188- .disableUpDownActions()
183+ }
184+ .setRemoveActionUpdater {
185+ updateActionAvailability(CommonActionsPanel .Buttons .REMOVE )
186+ true
187+ }
188+ .disableUpDownActions()
189189
190190 cell(toolbarDecorator.createPanel())
191- .align(Align .FILL )
191+ .align(Align .FILL )
192192 }.resizableRow()
193193 }.resizableRow()
194194
@@ -208,7 +208,7 @@ class AppSettingsConfigurable : BoundConfigurable(message("settings.general.grou
208208 }
209209
210210 override fun apply () {
211- AppSettings .instance.openAIHosts .add(hostComboBox.item)
211+ AppSettings .instance.currentLlmProvider.hosts .add(hostComboBox.item)
212212 promptTable.apply ()
213213 super .apply ()
214214 }
0 commit comments