Skip to content

Commit

Permalink
feat: update for app settings ui #25
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 18, 2023
1 parent 2c85f40 commit 5cef076
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/kotlin/cc/unitmesh/devti/settings/AppSettingsComponent.kt
Expand Up @@ -35,6 +35,7 @@ class AppSettingsComponent(settings: AutoDevSettingsState) {
private val aiEngine = ComboBox(AI_ENGINES)
private val customEngineServer = JBTextField()
private val customEngineToken = JBTextField()
private val customEngineResponse = JBTextField()
private val language = ComboBox(HUMAN_LANGUAGES)
private val maxTokenLengthInput = JBTextField()
//
Expand Down Expand Up @@ -78,10 +79,12 @@ class AppSettingsComponent(settings: AutoDevSettingsState) {

panel = FormBuilder.createFormBuilder()
.addLabeledComponent(JBLabel("Language: "), language, 1, false)
.addSeparator()
.addTooltip("For Custom LLM, config Custom Engine Server & Custom Engine Token & Custom Engine Response ")
.addLabeledComponent(JBLabel("AI Engine: "), aiEngine, 1, false)
.addLabeledComponent(JBLabel("Max Token Length: "), maxTokenLengthInput, 1, false)
.addSeparator()
.addTooltip("GitHub Token is for AutoDev")
.addTooltip("GitHub Token is for AutoCRUD Model")
.addLabeledComponent(JBLabel("GitHub Token: "), githubToken, 1, false)
.addSeparator()
.addLabeledComponent(JBLabel("OpenAI Model: "), openAiModel, 1, false)
Expand All @@ -90,8 +93,10 @@ class AppSettingsComponent(settings: AutoDevSettingsState) {
.addSeparator()
.addLabeledComponent(JBLabel("Custom Engine Server: "), customEngineServer, 1, false)
.addLabeledComponent(JBLabel("Custom Engine Token: "), customEngineToken, 1, false)
.addLabeledComponent(JBLabel("Custom Engine Response (Json Path): "), customEngineResponse, 1, false)
.addVerticalGap(2)
.addLabeledComponent(JBLabel("Custom Engine Prompt (Json): "), customEnginePrompt, 1, true)
.addSeparator()
.addLabeledComponent(JBLabel("Customize Prompt (Json): "), customEnginePrompt, 1, true)
.addComponentFillVertically(JPanel(), 0)
.panel

Expand Down Expand Up @@ -157,6 +162,14 @@ class AppSettingsComponent(settings: AutoDevSettingsState) {
customEngineToken.text = newText
}

private fun getCustomEngineResponse(): String {
return customEngineResponse.text
}

private fun setCustomEngineResponse(newText: String) {
customEngineResponse.text = newText
}

private fun getCustomEnginePrompt(): String {
return customEnginePrompt.text
}
Expand All @@ -181,6 +194,7 @@ class AppSettingsComponent(settings: AutoDevSettingsState) {
maxTokenLengthInput.text = newText
}


fun isModified(settings: AutoDevSettingsState): Boolean {
return settings.openAiKey != getOpenAiKey() ||
settings.githubToken != getGithubToken() ||
Expand Down

0 comments on commit 5cef076

Please sign in to comment.