Skip to content

Commit c1e90b2

Browse files
authored
Merge pull request #28 from devchat-ai/support-workflows
Support workflows
2 parents 6f64442 + c4edd0d commit c1e90b2

9 files changed

Lines changed: 200 additions & 273 deletions

File tree

src/main/kotlin/ai/devchat/cli/DevChatConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ class DevChatConfig {
8585
throw RuntimeException("Failed to save config", e)
8686
}
8787
}
88-
}
88+
}

src/main/kotlin/ai/devchat/cli/DevChatInstallationManager.kt

Lines changed: 0 additions & 200 deletions
This file was deleted.

src/main/kotlin/ai/devchat/cli/DevChatWrapper.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ai.devchat.common.Log
55
import ai.devchat.common.Settings
66
import com.alibaba.fastjson.JSON
77
import com.alibaba.fastjson.JSONArray
8+
import com.intellij.util.alsoIfNull
89
import com.intellij.util.containers.addIfNotNull
910
import kotlinx.coroutines.*
1011
import 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

Comments
 (0)