Skip to content

Commit 265d343

Browse files
committed
feat(coder): add disable history messages #54
1 parent 516a765 commit 265d343

File tree

7 files changed

+28
-4
lines changed

7 files changed

+28
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ enum class ChatActionType {
5757
COUNIT -> ""
5858
CODE_REVIEW -> ""
5959
CREATE_GENIUS -> ""
60-
GENERATE_TEST_DATA -> "Generate JSON for given $lang code. So that we can use it to test for APIs. \n" +
61-
"Make sure JSON contains real business logic, not just data structure. \n" +
62-
"For example, if the code is a function that returns a list of users, " +
63-
"the JSON should contain a list of users, not just a list of user objects."
60+
GENERATE_TEST_DATA -> "Generate JSON for given $lang code. So that we can use it to test for APIs. \n"
6461
}
6562
}
6663

src/main/kotlin/cc/unitmesh/devti/llms/azure/AzureOpenAIProvider.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class AzureOpenAIProvider(val project: Project) : LLMProvider {
9898
if (historyMessageLength > maxTokenLength) {
9999
messages.clear()
100100
}
101+
if (project.coderSetting.state.noChatHistory) {
102+
messages.clear()
103+
}
101104

102105
messages.add(SimpleOpenAIFormat.fromChatMessage(systemMessage))
103106
val requestText = Json.encodeToString<SimpleOpenAIBody>(

src/main/kotlin/cc/unitmesh/devti/llms/custom/CustomLLMProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cc.unitmesh.devti.gui.chat.ChatRole
44
import cc.unitmesh.devti.llms.LLMProvider
55
import cc.unitmesh.devti.settings.AutoDevSettingsState
66
import cc.unitmesh.devti.settings.ResponseType
7+
import cc.unitmesh.devti.settings.coder.coderSetting
78
import com.fasterxml.jackson.databind.ObjectMapper
89
import com.intellij.openapi.components.Service
910
import com.intellij.openapi.diagnostic.logger
@@ -71,6 +72,9 @@ class CustomLLMProvider(val project: Project) : LLMProvider {
7172
if (!keepHistory) {
7273
clearMessage()
7374
}
75+
if (project.coderSetting.state.noChatHistory) {
76+
messages.clear()
77+
}
7478

7579
messages += Message("user", promptText)
7680

src/main/kotlin/cc/unitmesh/devti/llms/openai/OpenAIProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class OpenAIProvider(val project: Project) : LLMProvider {
103103
clearMessage()
104104
}
105105

106+
if (project.coderSetting.state.noChatHistory) {
107+
messages.clear()
108+
}
109+
106110
var output = ""
107111
val completionRequest = prepareRequest(promptText, systemPrompt)
108112

src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderConfigurable.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
1414
private val recordingInLocalCheckBox = JCheckBox()
1515
private val disableAdvanceContextCheckBox = JCheckBox()
1616
private val inEditorCompletionCheckBox = JCheckBox()
17+
private val noChatHistoryCheckBox = JCheckBox()
18+
1719
private val explainCodeField = JTextField()
1820
private val refactorCodeField = JTextField()
1921
private val fixIssueCodeField = JTextField()
@@ -40,6 +42,16 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
4042
prop = state::disableAdvanceContext.toMutableProperty()
4143
)
4244
}
45+
46+
row(AutoDevBundle.message("settings.autodev.coder.noChatHistory")) {
47+
fullWidthCell(noChatHistoryCheckBox)
48+
.bind(
49+
componentGet = { it.isSelected },
50+
componentSet = { component, value -> component.isSelected = value },
51+
prop = state::noChatHistory.toMutableProperty()
52+
)
53+
}
54+
4355
row(AutoDevBundle.message("settings.autodev.coder.inEditorCompletion")) {
4456
fullWidthCell(inEditorCompletionCheckBox)
4557
.bind(
@@ -90,6 +102,7 @@ class AutoDevCoderConfigurable(project: Project) : BoundConfigurable(AutoDevBund
90102
it.refactorCode = state.refactorCode
91103
it.fixIssueCode = state.fixIssueCode
92104
it.generateTest = state.generateTest
105+
it.noChatHistory = state.noChatHistory
93106
}
94107
}
95108
}

src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderSettingService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class AutoDevCoderSettingService(
2222
var recordingInLocal by property(false)
2323
var disableAdvanceContext by property(false)
2424
var inEditorCompletion by property(false)
25+
var noChatHistory by property(false)
26+
2527
var explainCode: String by property("Explain \$lang code") { it.isEmpty() }
2628
var refactorCode: String by property("Refactor the given \$lang code") { it.isEmpty() }
2729
var fixIssueCode: String by property("Help me fix this issue") { it.isEmpty() }

src/main/resources/messages/AutoDevBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ settings.autodev.coder=AutoDev Coder
9191
settings.autodev.coder.recordingInLocal=Recording Instruction In Local
9292
settings.autodev.coder.disableAdvanceContext=Disable Advance Context (like framework context or others)
9393
settings.autodev.coder.inEditorCompletion=Completion in Editor
94+
settings.autodev.coder.noChatHistory=No Chat History
9495
settings.autodev.coder.explainCode=Explain code
9596
settings.autodev.coder.refactorCode=Refactor code
9697
settings.autodev.coder.fixIssueCode=Fix issue

0 commit comments

Comments
 (0)