@@ -5,6 +5,7 @@ import ai.devchat.common.Log
55import ai.devchat.common.Settings
66import com.alibaba.fastjson.JSON
77import com.alibaba.fastjson.JSONArray
8+ import com.intellij.util.alsoIfNull
89import com.intellij.util.containers.addIfNotNull
910import kotlinx.coroutines.*
1011import java.io.IOException
@@ -42,14 +43,14 @@ class DevChatWrapper(
4243 private val command : String = DevChatPathUtil .devchatBinPath,
4344 private var apiBase : String? = null ,
4445 private var apiKey : String? = null ,
45- private var currentModel : String? = null
46+ private var defaultModel : String? = null
4647) {
4748 init {
48- if (apiBase.isNullOrEmpty() || apiKey.isNullOrEmpty() || currentModel .isNullOrEmpty()) {
49+ if (apiBase.isNullOrEmpty() || apiKey.isNullOrEmpty() || defaultModel .isNullOrEmpty()) {
4950 val (key, api, model) = Settings .getAPISettings()
5051 apiBase = apiBase ? : api
5152 apiKey = apiKey ? : key
52- currentModel = currentModel ? : model
53+ defaultModel = defaultModel ? : model
5354 }
5455 }
5556
@@ -109,7 +110,10 @@ class DevChatWrapper(
109110
110111 val prompt: (MutableList <Pair <String , String ?>>, String , ((String ) -> Unit )? ) -> Unit get() = {
111112 flags: MutableList <Pair <String , String ?>>, message: String , callback: ((String ) -> Unit )? ->
112- flags.addAll(listOf (" model" to currentModel, " " to message))
113+ flags
114+ .find { it.first == " model" && ! it.second.isNullOrEmpty() }
115+ .alsoIfNull { flags.add(" model" to defaultModel) }
116+ flags.add(" " to message)
113117 subCommand(listOf (" prompt" ))(flags, callback)
114118 }
115119
0 commit comments