Skip to content

Commit

Permalink
fixed compatibility 223 problems
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbion committed May 9, 2023
1 parent 0fa1039 commit fb1dfaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.util.preferredWidth
import org.openasr.idiolect.recognizer.CustomMicrophone
import org.openasr.idiolect.settings.IdiolectConfig
import java.awt.BorderLayout
import java.awt.Dimension
import java.awt.event.ItemEvent
import java.io.ByteArrayOutputStream
import javax.sound.sampled.AudioSystem
Expand Down Expand Up @@ -78,19 +78,19 @@ class AudioTab : JComponent(), Disposable, AncestorListener {
row {
label("Volume").applyToComponent {
horizontalAlignment = JLabel.CENTER
preferredWidth = 50
preferredSize = Dimension(50, preferredSize.height)
}
label("Noise").applyToComponent {
horizontalAlignment = JLabel.CENTER
preferredWidth = 50
preferredSize = Dimension(50, preferredSize.height)
}
}
row {
cell(volumeSlider).applyToComponent {
preferredWidth = 50
preferredSize = Dimension(50, preferredSize.height)
}
cell(noiseLevelSlider).applyToComponent {
preferredWidth = 50
preferredSize = Dimension(50, preferredSize.height)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.observable.util.whenTextChanged
import com.intellij.openapi.wm.ToolWindow
import com.intellij.ui.dsl.builder.*
import com.intellij.ui.util.minimumWidth
import com.intellij.ui.util.preferredWidth
import com.intellij.util.application
import com.intellij.util.ui.UIUtil
import org.openasr.idiolect.actions.LlmCompletionAction
Expand All @@ -18,6 +17,7 @@ import org.openasr.idiolect.nlp.ai.OpenAiClient
import org.openasr.idiolect.presentation.components.FocusableTextArea
import org.openasr.idiolect.presentation.components.IdiolectHtmlEditorKit
import org.openasr.idiolect.settings.openai.OpenAiConfig
import java.awt.Dimension
import java.awt.Rectangle
import java.util.*
import javax.swing.JComponent
Expand All @@ -26,6 +26,8 @@ import javax.swing.JLabel
import javax.swing.JSlider
import javax.swing.event.AncestorEvent
import javax.swing.event.AncestorListener
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener
import kotlin.reflect.KFunction1
import kotlin.reflect.KMutableProperty0

Expand All @@ -48,7 +50,7 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener

initialiseLogPane()

userInput.minimumWidth = 500
userInput.minimumSize = Dimension(500, userInput.minimumSize.height)
userInput.emptyText.text = "Enter prompt here..."

updateModels()
Expand All @@ -71,15 +73,15 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener
intTextField(IntRange(1,4096), 16).columns(COLUMNS_TINY).label("Max tokens")
.applyToComponent {
toolTipText = "The maximum number of tokens the LLM will generate"
}
.onChanged {
if (it.text.isNotEmpty()) {
try {
val value = it.text.toInt()
OpenAiConfig.settings.maxTokens = value
aiService.setMaxTokens(value)
} catch (e: Exception) {
log.info("Invalid max token. Must be an integer value <= 4096")
document.whenTextChanged {
if (text.isNotEmpty()) {
try {
val value = text.toInt()
OpenAiConfig.settings.maxTokens = value
aiService.setMaxTokens(value)
} catch (e: Exception) {
log.info("Invalid max token. Must be an integer value <= 4096")
}
}
}
}
Expand Down Expand Up @@ -170,7 +172,7 @@ class ChatTab(private val toolWindow: ToolWindow) : Disposable, AncestorListener

return slider(0, scale, 1, scale / 2)
.applyToComponent {
preferredWidth = 100
preferredSize = Dimension(100,20)
// labelTable = sliderLabels
// paintTicks = false
paintLabels = false
Expand Down

0 comments on commit fb1dfaf

Please sign in to comment.