Skip to content

Commit

Permalink
1.2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Nov 12, 2023
1 parent 3d13280 commit 572ab25
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## [Unreleased]

## [1.2.18]

### Improved
- Code Chat
- Various fixes
- Added GPT4 Turbo support

## [1.2.14]

### Improved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBPasswordField
Expand Down Expand Up @@ -45,8 +46,8 @@ class AppSettingsComponent {
val suppressErrors = JBCheckBox()

@Suppress("unused")
@Name("Use GPT-4")
val useGPT4 = JBCheckBox()
@Name("Model")
val modelName = ComboBox<String>()

@Suppress("unused")
@Name("Enable API Log")
Expand Down Expand Up @@ -101,6 +102,9 @@ class AppSettingsComponent {

init {
tokenCounter.isEditable = false
this.modelName.addItem(OpenAIClient.Models.GPT35Turbo.modelName)
this.modelName.addItem(OpenAIClient.Models.GPT4.modelName)
this.modelName.addItem(OpenAIClient.Models.GPT4Turbo.modelName)
}

val preferredFocusedComponent: JComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AppSettingsConfigurable : Configurable {
synchronized(this) {
if (null == mainPanel) {
settingsComponent = AppSettingsComponent()
reset()
mainPanel = UITools.build(settingsComponent!!, false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
val listeningEndpoint: String = "localhost"
val modalTasks: Boolean = false
var suppressErrors: Boolean = false
private var apiLog: Boolean = false
var apiLog: Boolean = false
var apiBase = "https://api.openai.com/v1"
var apiKey = ""
var temperature = 0.1
var useGPT4 = true
var modelName : String = OpenAIClient.Models.GPT35Turbo.modelName
var tokenCounter = 0
var humanLanguage = "English"
var devActions = false
Expand All @@ -38,7 +38,7 @@ class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
return createChatRequest(defaultChatModel())
}

fun defaultChatModel() = if (useGPT4) OpenAIClient.Models.GPT4 else OpenAIClient.Models.GPT35Turbo
fun defaultChatModel() = OpenAIClient.Models.entries.first { it.modelName == modelName }

private fun createChatRequest(model: OpenAIClient.Model): ChatRequest {
val chatRequest = ChatRequest()
Expand Down Expand Up @@ -72,7 +72,7 @@ class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
if (humanLanguage != that.humanLanguage) return false
if (apiBase != that.apiBase) return false
if (apiKey != that.apiKey) return false
if (useGPT4 != that.useGPT4) return false
if (modelName != that.modelName) return false
if (apiLog != that.apiLog) return false
if (devActions != that.devActions) return false
if (editRequests != that.editRequests) return false
Expand All @@ -85,7 +85,7 @@ class AppSettingsState : PersistentStateComponent<SimpleEnvelope> {
apiBase,
apiKey,
temperature,
useGPT4,
modelName,
apiLog,
devActions,
editRequests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.intellij.ui.SimpleListCellRenderer
import com.intellij.ui.popup.list.ComboBoxPopup
import com.simiacryptus.openai.OpenAIClient
import kotlinx.coroutines.CoroutineScope
import java.awt.event.MouseEvent
import javax.swing.JList
import javax.swing.ListCellRenderer
import javax.swing.ListModel
Expand All @@ -27,6 +26,7 @@ class ModelSelectionWidgetFactory : StatusBarWidgetFactory {
private var statusBar: StatusBar? = null
private var activeModel: String = AppSettingsState.instance.defaultChatModel().modelName
val models = listOf(
OpenAIClient.Models.GPT4Turbo,
OpenAIClient.Models.GPT4,
OpenAIClient.Models.GPT35Turbo,
)
Expand Down Expand Up @@ -80,7 +80,7 @@ class ModelSelectionWidgetFactory : StatusBarWidgetFactory {
}
return ComboBoxPopup(context, activeModel, { str ->
activeModel = str
AppSettingsState.instance.useGPT4 = (str == OpenAIClient.Models.GPT4.modelName)
AppSettingsState.instance.modelName = str
statusBar?.updateWidget(ID())
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import javax.swing.*
import javax.swing.text.JTextComponent
import kotlin.reflect.KMutableProperty
import kotlin.reflect.KProperty1
import kotlin.reflect.KVisibility
import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.isAccessible
import kotlin.reflect.jvm.javaField
Expand Down Expand Up @@ -324,7 +325,11 @@ object UITools {
val componentClass: Class<*> = component.javaClass
val declaredUIFields =
componentClass.kotlin.memberProperties.map { it.name }.toSet()
for (settingsField in settings.javaClass.kotlin.memberProperties) {
val memberProperties = settings.javaClass.kotlin.memberProperties
val publicProperties = memberProperties.filter {
it.visibility == KVisibility.PUBLIC //&& it is KMutableProperty<*>
}
for (settingsField in publicProperties) {
val fieldName = settingsField.name
try {
if (!declaredUIFields.contains(fieldName)) continue
Expand Down

0 comments on commit 572ab25

Please sign in to comment.