diff --git a/src/main/kotlin/cc/unitmesh/devti/agent/configurable/CoUnitSettingService.kt b/src/main/kotlin/cc/unitmesh/devti/agent/configurable/CoUnitSettingService.kt index 76edb73eee..bae809b858 100644 --- a/src/main/kotlin/cc/unitmesh/devti/agent/configurable/CoUnitSettingService.kt +++ b/src/main/kotlin/cc/unitmesh/devti/agent/configurable/CoUnitSettingService.kt @@ -12,6 +12,10 @@ class CoUnitProjectSettingsService( val project: Project, ) : SimplePersistentStateComponent(CoUnitProjectSettings()) { val enableCustomRag: Boolean get() = state.enableCustomRag + + /** + * Use [cc.unitmesh.devti.agent.model.CustomAgentConfig.loadFromProject] + */ val ragsJsonConfig: String get() = state.agentJsonConfig fun modify(action: (CoUnitProjectSettings) -> Unit) { diff --git a/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt b/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt index 7e3c1f153c..d571339937 100644 --- a/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt +++ b/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt @@ -183,15 +183,9 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab } private fun loadRagApps(): List { - val ragsJsonConfig = project.customAgentSetting.ragsJsonConfig - if (ragsJsonConfig.isEmpty()) return listOf(defaultRag) - - val rags = try { - Json.decodeFromString>(ragsJsonConfig) - } catch (e: Exception) { - logger.warn("Failed to parse custom rag apps", e) - listOf() - } + val rags = CustomAgentConfig.loadFromProject(project) + + if (rags.isEmpty()) return listOf(defaultRag) return listOf(defaultRag) + rags } diff --git a/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/TestCodeGenTask.kt b/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/TestCodeGenTask.kt index 2b4a4199b6..8b9d62614e 100644 --- a/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/TestCodeGenTask.kt +++ b/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/TestCodeGenTask.kt @@ -210,20 +210,8 @@ class TestCodeGenTask(val request: TestCodeGenRequest) : } private fun loadRagApp(): CustomAgentConfig? { - val ragsJsonConfig = project.customAgentSetting.ragsJsonConfig - if (ragsJsonConfig.isEmpty()) return null - - val rags = try { - Json.decodeFromString>(ragsJsonConfig) - } catch (e: Exception) { - logger.warn("Failed to parse custom rag apps", e) - listOf() - } - - if (rags.isEmpty()) { - return null - } - + val rags = CustomAgentConfig.loadFromProject(project) + if (rags.isEmpty()) return null return rags.firstOrNull { it.name == CustomExtContext.TextContext.agentName } }