File tree Expand file tree Collapse file tree 5 files changed +32
-5
lines changed
src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin Expand file tree Collapse file tree 5 files changed +32
-5
lines changed Original file line number Diff line number Diff line change 22
33## [ Unreleased]
44
5+ ### Changed
6+
7+ - Temperature is no longer a required field for OpenAI client configuration (#360 ).
8+
59## [ 2.13.0] - 2025-06-17
610
711### Added
Original file line number Diff line number Diff line change @@ -36,6 +36,19 @@ fun ValidationInfoBuilder.temperatureValid(value: String): ValidationInfo? {
3636 return error(message(" validation.temperature" ))
3737}
3838
39+ fun ValidationInfoBuilder.temperatureValidNullable (value : String ): ValidationInfo ? {
40+ if (value.isNotBlank()) {
41+ value.toFloatOrNull().let {
42+ return if (it != null && it in 0.0 .. 2.0 ) {
43+ null
44+ } else {
45+ error(message(" validation.temperature" ))
46+ }
47+ }
48+ }
49+ return null
50+ }
51+
3952fun ValidationInfoBuilder.unique (value : String , existingValues : Set <String >): ValidationInfo ? =
4053 if (existingValues.contains(value)) error(message(" validation.unique" )) else null
4154
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients
33import com.github.blarc.ai.commits.intellij.plugin.*
44import com.github.blarc.ai.commits.intellij.plugin.AICommitsBundle.message
55import com.intellij.openapi.ui.ComboBox
6+ import com.intellij.openapi.ui.ValidationInfo
67import com.intellij.ui.components.JBLabel
78import com.intellij.ui.components.JBTextField
89import com.intellij.ui.dsl.builder.*
10+ import com.intellij.ui.layout.ValidationInfoBuilder
911import kotlin.reflect.KMutableProperty0
1012
1113
@@ -94,15 +96,15 @@ abstract class LLMClientPanel(
9496 }
9597 }
9698
97- open fun Panel.temperatureRow () {
99+ open fun Panel.temperatureRow (validation : ValidationInfoBuilder .( String ) -> ValidationInfo ? = ValidationInfoBuilder : :temperatureValid ) {
98100 row {
99101 label(message(" settings.llmClient.temperature" ))
100102 .widthGroup(" label" )
101103
102104 cell(temperatureTextField)
103105 .bindText(clientConfiguration::temperature)
104106 .align(Align .FILL )
105- .validationOnInput { temperatureValid (it.text) }
107+ .validationOnInput { validation (it.text) }
106108 .resizableColumn()
107109
108110 contextHelp(message(" settings.llmClient.temperature.comment" ))
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients.openAi
33import com.github.blarc.ai.commits.intellij.plugin.AICommitsBundle.message
44import com.github.blarc.ai.commits.intellij.plugin.emptyText
55import com.github.blarc.ai.commits.intellij.plugin.settings.clients.LLMClientPanel
6+ import com.github.blarc.ai.commits.intellij.plugin.temperatureValidNullable
67import com.intellij.ui.components.JBPasswordField
78import com.intellij.ui.components.JBTextField
89import com.intellij.ui.dsl.builder.*
10+ import com.intellij.ui.layout.ValidationInfoBuilder
911
1012class OpenAiClientPanel (private val clientConfiguration : OpenAiClientConfiguration ) : LLMClientPanel(clientConfiguration) {
1113 private val tokenPasswordField = JBPasswordField ()
@@ -19,7 +21,7 @@ class OpenAiClientPanel(private val clientConfiguration: OpenAiClientConfigurati
1921 tokenRow()
2022 modelIdRow()
2123 organizationIdRow()
22- temperatureRow()
24+ temperatureRow(ValidationInfoBuilder ::temperatureValidNullable )
2325 topPDoubleRow(topPTextField, clientConfiguration::topP.toNullableProperty())
2426 verifyRow()
2527
Original file line number Diff line number Diff line change @@ -31,11 +31,14 @@ class OpenAiClientService(private val cs: CoroutineScope) : LLMClientService<Ope
3131 val builder = OpenAiChatModel .builder()
3232 .apiKey(token ? : " " )
3333 .modelName(client.modelId)
34- .temperature(client.temperature.toDouble())
3534 .timeout(Duration .ofSeconds(client.timeout.toLong()))
3635 .topP(client.topP)
3736 .baseUrl(client.host)
3837
38+ client.temperature.takeIf { it.isNotBlank() }?.let {
39+ builder.temperature(it.toDouble())
40+ }
41+
3942 client.organizationId?.takeIf { it.isNotBlank() }?.let {
4043 builder.organizationId(it)
4144 }
@@ -48,11 +51,14 @@ class OpenAiClientService(private val cs: CoroutineScope) : LLMClientService<Ope
4851 val builder = OpenAiStreamingChatModel .builder()
4952 .apiKey(token ? : " " )
5053 .modelName(client.modelId)
51- .temperature(client.temperature.toDouble())
5254 .timeout(Duration .ofSeconds(client.timeout.toLong()))
5355 .topP(client.topP)
5456 .baseUrl(client.host)
5557
58+ client.temperature.takeIf { it.isNotBlank() }?.let {
59+ builder.temperature(it.toDouble())
60+ }
61+
5662 client.organizationId?.takeIf { it.isNotBlank() }?.let {
5763 builder.organizationId(it)
5864 }
You can’t perform that action at this time.
0 commit comments