Skip to content

Commit

Permalink
feat: add config for disable advanced prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jan 5, 2024
1 parent 6152514 commit 40b61f1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/provider/ContextPrompter.kt
Expand Up @@ -4,6 +4,7 @@ import cc.unitmesh.devti.gui.chat.ChatActionType
import cc.unitmesh.devti.provider.builtin.DefaultContextPrompter
import cc.unitmesh.devti.provider.context.ChatContextProvider
import cc.unitmesh.devti.provider.context.ChatCreationContext
import cc.unitmesh.devti.settings.custom.teamPromptsSettings
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.project.Project
Expand All @@ -24,6 +25,10 @@ abstract class ContextPrompter : LazyExtensionInstance<ContextPrompter>() {
private val chatContextCache: MutableMap<ChatCreationContext, String> = mutableMapOf()

suspend fun collectionContext(creationContext: ChatCreationContext): String {
if (project?.teamPromptsSettings?.state?.disableAdvanceContext == true) {
return ""
}

if (chatContextCache.containsKey(creationContext)) {
val cachedContent = chatContextCache[creationContext]!!
if (cachedContent.isNotEmpty()) {
Expand Down
Expand Up @@ -14,6 +14,7 @@ class PromptLibraryConfigurable(project: Project) : BoundConfigurable(AutoDevBun

private val teamPromptsField = JTextField()
private val recordingInLocalField = JCheckBox()
private val disableAdvanceContextField = JCheckBox()

val settings = project.service<TeamPromptsProjectSettingsService>()
val state = settings.state.copy()
Expand All @@ -37,10 +38,20 @@ class PromptLibraryConfigurable(project: Project) : BoundConfigurable(AutoDevBun
)
}

row(AutoDevBundle.message("settings.external.team.prompts.disableAdvanceContext")) {
fullWidthCell(disableAdvanceContextField)
.bind(
componentGet = { it.isSelected },
componentSet = { component, value -> component.isSelected = value },
prop = state::disableAdvanceContext.toMutableProperty()
)
}

onApply {
settings.modify {
it.teamPromptsDir = state.teamPromptsDir
it.recordingInLocal = state.recordingInLocal
it.disableAdvanceContext
}
}
}
Expand Down
Expand Up @@ -21,6 +21,7 @@ class TeamPromptsProjectSettingsService(
class TeamPromptsSettings : AdProjectSettingsBase<TeamPromptsSettings>() {
var teamPromptsDir by property("prompts") { it.isEmpty() }
var recordingInLocal by property(false)
var disableAdvanceContext by property(false)

override fun copy(): TeamPromptsSettings {
val state = TeamPromptsSettings()
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages/AutoDevBundle.properties
Expand Up @@ -87,3 +87,4 @@ action.new.genius.cicd.github=Generate GitHub Actions
settings.external.team.prompts.path=Team Prompts Path
settings.external.team.prompts.name=Team Prompts
settings.external.team.prompts.recordingInLocal=Recording Instruction In Local
settings.external.team.prompts.disableAdvanceContext=Disable Advance Context (like framework context or others)

0 comments on commit 40b61f1

Please sign in to comment.