From e59919618549eeabffb68f4d8ee2adb76c28b2d5 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sun, 17 Mar 2024 14:46:13 +0800 Subject: [PATCH] feat(chat): add custom agent response provider #101 Add a custom agent response provider to handle custom agent responses. This allows for customizable behavior based on the specific agent used. --- .../main/resources/META-INF/autodev-core.xml | 4 +++ .../main/resources/META-INF/autodev-core.xml | 4 +++ .../provider/custom/AgentResponseProvider.kt | 26 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/main/kotlin/cc/unitmesh/devti/provider/custom/AgentResponseProvider.kt diff --git a/src/222/main/resources/META-INF/autodev-core.xml b/src/222/main/resources/META-INF/autodev-core.xml index d6f1f29424..38fd7fa245 100644 --- a/src/222/main/resources/META-INF/autodev-core.xml +++ b/src/222/main/resources/META-INF/autodev-core.xml @@ -159,6 +159,10 @@ + + diff --git a/src/233/main/resources/META-INF/autodev-core.xml b/src/233/main/resources/META-INF/autodev-core.xml index 487a7266cc..b402e650a4 100644 --- a/src/233/main/resources/META-INF/autodev-core.xml +++ b/src/233/main/resources/META-INF/autodev-core.xml @@ -159,6 +159,10 @@ + + diff --git a/src/main/kotlin/cc/unitmesh/devti/provider/custom/AgentResponseProvider.kt b/src/main/kotlin/cc/unitmesh/devti/provider/custom/AgentResponseProvider.kt new file mode 100644 index 0000000000..b5314f94fd --- /dev/null +++ b/src/main/kotlin/cc/unitmesh/devti/provider/custom/AgentResponseProvider.kt @@ -0,0 +1,26 @@ +package cc.unitmesh.devti.provider.custom + +import cc.unitmesh.devti.agent.model.CustomAgentConfig +import com.intellij.openapi.extensions.ExtensionPointName +import com.intellij.openapi.project.Project +import com.intellij.util.concurrency.annotations.RequiresBackgroundThread + +data class CustomAgentContext( + val config: CustomAgentConfig, + val response: String +) + +internal interface AgentResponseProvider { + val name: String + + @RequiresBackgroundThread + fun execute(project: Project, context: CustomAgentContext): String + + companion object { + val EP_NAME = ExtensionPointName("cc.unitmesh.customAgentResponse") + + fun instance(name: String): List { + return EP_NAME.extensionList.filter { it.name == name } + } + } +} \ No newline at end of file