Skip to content

Commit

Permalink
feat(agent): add support for DevIns language in code blocks #144
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 11, 2024
1 parent df04902 commit ddd7565
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
8 changes: 8 additions & 0 deletions docs/agent/agent-action.md
Expand Up @@ -49,4 +49,12 @@ enum class ResponseAction {
<img src="https://unitmesh.cc/auto-dev/custom-agent-webview.png" alt="Custom AI Agent Dropdown" width="600px"/>

### DevIns

> The DevIns response action will handle the response in the DevIns language.
just like the following example:

```
/write:xxx.java#L1-L12
```
Expand Up @@ -57,9 +57,9 @@ class CustomAgentChatProcessor(val project: Project) {
message.reRenderAssistantOutput()

val code = Code.parse(content)
if (code.language.displayName == "DevIn") {
devInCode = code.text
}
if (code.language.displayName == "DevIn") {
devInCode = code.text
}

ui.hiddenProgressBar()
ui.updateUI()
Expand Down Expand Up @@ -116,6 +116,20 @@ class CustomAgentChatProcessor(val project: Project) {
ui.appendWebView(content, project)
ui.hiddenProgressBar()
}

CustomAgentResponseAction.DevIns -> {
ui.addMessage(AutoDevBundle.message("autodev.loading"))
var msg = ""
LLMCoroutineScope.scope(project).launch {
msg = ui.updateMessage(response)
}

llmProvider.appendLocalMessage(msg, ChatRole.Assistant)
ui.hiddenProgressBar()
ui.updateUI()

devInCode = msg
}
}

if (!devInCode.isNullOrEmpty()) {
Expand Down
Expand Up @@ -34,5 +34,10 @@ enum class CustomAgentResponseAction {
/**
* Display result in WebView
*/
WebView
WebView,

/**
* Handle with DevIns language in code block
*/
DevIns
}
2 changes: 1 addition & 1 deletion src/main/kotlin/cc/unitmesh/devti/util/parser/CodeUtil.kt
Expand Up @@ -57,7 +57,7 @@ class Code(val language: Language, val text: String, val isComplete: Boolean) {
return Code(findLanguage("markdown"), content.replace("\\n", "\n"), codeClosed)
}

if (languageId == "devin") {
if (languageId == "devin" || languageId == "devins") {
trimmedCode = trimmedCode.replace("\\`\\`\\`", "```")
}

Expand Down
Expand Up @@ -50,7 +50,8 @@
"enum": [
"Direct",
"TextChunk",
"WebView"
"WebView",
"DevIns"
]
}
},
Expand Down

0 comments on commit ddd7565

Please sign in to comment.