1
1
package cc.unitmesh.devti.settings.coder
2
2
3
3
import cc.unitmesh.devti.AutoDevBundle
4
+ import cc.unitmesh.devti.custom.schema.INLAY_PROMPTS_FILE_NAME
4
5
import cc.unitmesh.devti.fullWidthCell
6
+ import cc.unitmesh.devti.gui.component.JsonLanguageField
7
+ import cc.unitmesh.devti.settings.ResponseType
5
8
import com.intellij.openapi.components.service
6
9
import com.intellij.openapi.options.BoundConfigurable
7
10
import com.intellij.openapi.project.Project
11
+ import com.intellij.openapi.ui.ComboBox
8
12
import com.intellij.openapi.ui.DialogPanel
9
- import com.intellij.ui.dsl.builder.*
13
+ import com.intellij.ui.dsl.builder.panel
14
+ import com.intellij.ui.dsl.builder.toMutableProperty
15
+ import com.intellij.util.containers.toArray
10
16
import javax.swing.JCheckBox
17
+ import javax.swing.JPasswordField
11
18
import javax.swing.JTextField
12
19
13
20
class AutoDevCoderConfigurable (project : Project ) : BoundConfigurable(AutoDevBundle .message("settings.autodev.coder")) {
@@ -21,11 +28,22 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
21
28
private val explainCodeField = JTextField ()
22
29
private val refactorCodeField = JTextField ()
23
30
private val fixIssueCodeField = JTextField ()
24
- private val generateTestField = JTextField ()
31
+
25
32
private val useCustomAIEngineWhenInlayCodeComplete = JCheckBox ()
26
33
.apply {
27
34
toolTipText = " You can use custom LLM to inlay complete code."
28
35
}
36
+ private val maxTokenLengthParam = JTextField ()
37
+ private val delaySecondsParam: JTextField = JTextField ()
38
+ private val customEngineResponseTypeParam: ComboBox <String > = ComboBox (ResponseType .values().map { it.name }.toArray(emptyArray()));
39
+ private val customEngineResponseFormatParam = JTextField ()
40
+ private val customEngineRequestBodyFormatParam = JTextField ()
41
+ private val customEngineServerParam = JTextField ()
42
+ private val customEngineTokenParam = JPasswordField ()
43
+ private val customEnginePrompt = JsonLanguageField (project, " " , " Custom your prompt here" , INLAY_PROMPTS_FILE_NAME )
44
+
45
+ private val generateTestField = JTextField ()
46
+
29
47
val settings = project.service<AutoDevCoderSettingService >()
30
48
val state = settings.state.copy()
31
49
@@ -107,6 +125,78 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
107
125
)
108
126
}
109
127
128
+ row(AutoDevBundle .message(" settings.autodev.coder.delaySecondsParam" )) {
129
+ fullWidthCell(delaySecondsParam)
130
+ .bind(
131
+ componentGet = { it.text },
132
+ componentSet = { component, value -> component.text = value },
133
+ prop = state::delaySecondsParam.toMutableProperty()
134
+ )
135
+ }
136
+
137
+ row(AutoDevBundle .message(" settings.autodev.coder.maxTokenLengthParam" )) {
138
+ fullWidthCell(maxTokenLengthParam)
139
+ .bind(
140
+ componentGet = { it.text },
141
+ componentSet = { component, value -> component.text = value },
142
+ prop = state::maxTokenLengthParam.toMutableProperty()
143
+ )
144
+ }
145
+
146
+ row(AutoDevBundle .message(" settings.autodev.coder.customEngineResponseTypeParam" )) {
147
+ fullWidthCell(customEngineResponseTypeParam)
148
+ .bind(
149
+ componentGet = { it.selectedItem?.toString() ? : ResponseType .SSE .name },
150
+ componentSet = { component, value -> component.selectedItem = value },
151
+ prop = state::customEngineResponseTypeParam.toMutableProperty()
152
+ )
153
+ }
154
+
155
+ row(AutoDevBundle .message(" settings.autodev.coder.customEngineResponseFormatParam" )) {
156
+ fullWidthCell(customEngineResponseFormatParam)
157
+ .bind(
158
+ componentGet = { it.text },
159
+ componentSet = { component, value -> component.text = value },
160
+ prop = state::customEngineResponseFormatParam.toMutableProperty()
161
+ )
162
+ }
163
+
164
+ row(AutoDevBundle .message(" settings.autodev.coder.customEngineRequestBodyFormatParam" )) {
165
+ fullWidthCell(customEngineRequestBodyFormatParam)
166
+ .bind(
167
+ componentGet = { it.text },
168
+ componentSet = { component, value -> component.text = value },
169
+ prop = state::customEngineRequestBodyFormatParam.toMutableProperty()
170
+ )
171
+ }
172
+
173
+ row(AutoDevBundle .message(" settings.autodev.coder.customEngineServerParam" )) {
174
+ fullWidthCell(customEngineServerParam)
175
+ .bind(
176
+ componentGet = { it.text },
177
+ componentSet = { component, value -> component.text = value },
178
+ prop = state::customEngineServerParam.toMutableProperty()
179
+ )
180
+ }
181
+ row(AutoDevBundle .message(" settings.autodev.coder.customEngineTokenParam" )) {
182
+ fullWidthCell(customEngineTokenParam)
183
+ .bind(
184
+ componentGet = { it.text },
185
+ componentSet = { component, value -> component.text = value },
186
+ prop = state::customEngineTokenParam.toMutableProperty()
187
+ )
188
+ }
189
+ row(AutoDevBundle .message(" settings.autodev.coder.customEnginePrompt" )){}
190
+ row() {
191
+ // TODO: spike better way for support 213 and 221
192
+ fullWidthCell(customEnginePrompt)
193
+ .bind(
194
+ componentGet = { it.text },
195
+ componentSet = { component, value -> component.text = value },
196
+ prop = state::customEnginePrompt.toMutableProperty()
197
+ )
198
+ }
199
+
110
200
onApply {
111
201
settings.modify {
112
202
it.recordingInLocal = state.recordingInLocal
@@ -117,6 +207,14 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
117
207
it.fixIssueCode = state.fixIssueCode
118
208
it.generateTest = state.generateTest
119
209
it.useCustomAIEngineWhenInlayCodeComplete = state.useCustomAIEngineWhenInlayCodeComplete
210
+ it.delaySecondsParam = state.delaySecondsParam
211
+ it.maxTokenLengthParam = state.maxTokenLengthParam
212
+ it.customEngineResponseTypeParam = state.customEngineResponseTypeParam
213
+ it.customEngineResponseFormatParam = state.customEngineResponseFormatParam
214
+ it.customEngineRequestBodyFormatParam = state.customEngineRequestBodyFormatParam
215
+ it.customEngineServerParam = state.customEngineServerParam
216
+ it.customEngineTokenParam = state.customEngineTokenParam
217
+ it.customEnginePrompt = state.customEnginePrompt
120
218
it.noChatHistory = state.noChatHistory
121
219
}
122
220
}
0 commit comments