Skip to content

Commit 3f19fae

Browse files
committed
refactor(chat): add support for custom RAG settings in chat coding service #51
This commit introduces the ability to handle custom RAG settings in the chat coding service. It modifies the `ChatCodingService` to check if custom RAG is enabled and if the user has selected a custom RAG. If both conditions are met, the chat is processed using the custom RAG settings. The `CoUnitPreProcessor` is modified to include a new method `isCustomRag` which checks if the input string starts with `CO_UNIT` and if custom RAG is enabled. The `CustomRagSettings` class is also introduced to manage the custom RAG configuration. The `AutoDevInputSection` and `ChatCodingPanel` are updated to expose methods `usedCustomRag` and `selectedCustomRag` to check if the user has selected a custom RAG. These methods are used in the `ChatCodingService` to determine if custom RAG processing should be applied.
1 parent 6a7c26a commit 3f19fae

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

src/main/kotlin/cc/unitmesh/devti/counit/CoUnitPreProcessor.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ class CoUnitPreProcessor(val project: Project) {
2222
private val coUnitPromptGenerator = CoUnitPromptGenerator(project)
2323
private val llmProvider = llmFactory.create(project)
2424

25-
fun isCustomRag(input: String): Boolean {
26-
// handle current category
27-
return project.customRagSettings.enableCustomRag && input.startsWith(CO_UNIT)
28-
}
29-
3025
fun handleChat(prompter: ContextPrompter, ui: ChatCodingPanel, context: ChatContext?) {
3126
val originRequest = prompter.requestPrompt()
3227
ui.addMessage(originRequest, true, originRequest)

src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.intellij.openapi.wm.impl.InternalDecorator
2222
import com.intellij.temporary.gui.block.AutoDevCoolBorder
2323
import com.intellij.ui.JBColor
2424
import com.intellij.ui.content.ContentManager
25-
import com.intellij.ui.popup.list.ComboBoxPopup
2625
import com.intellij.util.EventDispatcher
2726
import com.intellij.util.ui.JBEmptyBorder
2827
import com.intellij.util.ui.JBUI
@@ -188,7 +187,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
188187
return ValidationInfo(errorMessage, this as JComponent).asWarning()
189188
}
190189

191-
fun usedCustomRag(): Boolean {
190+
fun selectedCustomRag(): Boolean {
192191
return customRag.selectedItem != "Normal"
193192
}
194193

src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
245245
updateUI()
246246
}
247247

248-
fun usedCustomRag(): Boolean {
249-
return inputSection.usedCustomRag()
248+
fun selectedCustomRag(): Boolean {
249+
return inputSection.selectedCustomRag()
250250
}
251251
}

src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cc.unitmesh.cf.core.llms.LlmMsg
44
import cc.unitmesh.devti.AutoDevBundle
55
import cc.unitmesh.devti.util.LLMCoroutineScope
66
import cc.unitmesh.devti.counit.CoUnitPreProcessor
7+
import cc.unitmesh.devti.counit.configurable.customRagSettings
78
import cc.unitmesh.devti.llms.LlmFactory
89
import cc.unitmesh.devti.util.parser.PostCodeProcessor
910
import cc.unitmesh.devti.provider.ContextPrompter
@@ -33,7 +34,7 @@ class ChatCodingService(var actionType: ChatActionType, val project: Project) {
3334
val requestPrompt = prompter.requestPrompt()
3435
val displayPrompt = prompter.displayPrompt()
3536

36-
if (counitProcessor.isCustomRag(requestPrompt) && ui.usedCustomRag()) {
37+
if (project.customRagSettings.enableCustomRag && ui.selectedCustomRag()) {
3738
counitProcessor.handleChat(prompter, ui, context)
3839
return
3940
}

0 commit comments

Comments
 (0)