Skip to content

Commit

Permalink
Merge pull request #3213 from continuedev/pe/jb-apply-bugfix
Browse files Browse the repository at this point in the history
bugfix: use correct config.json when applying
  • Loading branch information
Patrick-Erichsen authored Dec 6, 2024
2 parents 2593515 + 7e466e7 commit 44bc6eb
Showing 1 changed file with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import java.net.NetworkInterface
import java.nio.charset.Charset
import java.nio.file.Paths
import java.util.*
import kotlin.coroutines.resume


fun uuid(): String {
Expand Down Expand Up @@ -106,7 +107,9 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) :
for (event in events) {
if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith(
".continue\\config.json"
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json")
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(
".continuerc.json"
)
) {
return object : AsyncFileListener.ChangeApplier {
override fun afterVfsChange() {
Expand Down Expand Up @@ -662,18 +665,41 @@ class IdeProtocolClient(
var llm = getModelByRole(config, "applyCodeBlock")

if (llm == null) {
val models = (config as? Map<*, *>)?.get("models") as? List<Map<*, *>>
llm = models?.find { model -> model["title"] == curSelectedModelTitle } as Map<String, Any>

if (llm == null) {
showToast("error", "Model '$curSelectedModelTitle' not found in config.")
llm = try {
suspendCancellableCoroutine { continuation ->
continuePluginService.coreMessenger?.request(
"config/getSerializedProfileInfo",
null,
null
) { response ->
val models =
((response as Map<String, Any>)["config"] as Map<String, Any>)["models"] as List<Map<String, Any>>
val foundModel = models.find { it["title"] == curSelectedModelTitle }

if (foundModel == null) {
launch {
showToast(
"error",
"Model '$curSelectedModelTitle' not found in config."
)
}
continuation.resume(null)
} else {
continuation.resume(foundModel)
}
}
}
} catch (e: Exception) {
launch { showToast("error", "Failed to fetch model configuration") }
respond(null)
return@launch
}
}


val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: ""


val prompt =
"The following code was suggested as an edit:\n```\n${text}\n```\nPlease apply it to the previous code."

Expand Down

0 comments on commit 44bc6eb

Please sign in to comment.