Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc78ab07

Browse files
committed
feat(chat): add LLM request cancellation support#394
Implement proper cancellation for chat coding service by adding support for LLMProvider2 cancellation and ensuring cleanup when stopping or clearing sessions. Addresses issue#394.
1 parentf09d66a commitc78ab07

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import cc.unitmesh.devti.custom.compile.CustomVariable
99
importcc.unitmesh.devti.gui.chat.message.ChatActionType
1010
importcc.unitmesh.devti.gui.chat.message.ChatContext
1111
importcc.unitmesh.devti.gui.chat.message.ChatRole
12+
importcc.unitmesh.devti.llm2.LLMProvider2
1213
importcc.unitmesh.devti.llms.LlmFactory
1314
importcc.unitmesh.devti.llms.custom.Message
1415
importcc.unitmesh.devti.provider.ContextPrompter
@@ -28,9 +29,18 @@ class ChatCodingService(var actionType: ChatActionType, val project: Project) {
2829
fungetLabel():String="$actionType Code"
2930

3031
funstop() {
32+
// Cancel the coroutine job
3133
currentJob?.cancel()
34+
35+
// Also cancel the underlying LLM provider if it supports cancellation
36+
if (llmProviderisLLMProvider2) {
37+
(llmProviderasLLMProvider2).cancelCurrentRequestSync()
38+
}
39+
40+
currentJob=null
3241
}
3342

43+
3444
privatevar isLastAgent:Boolean=false
3545

3646
funhandlePromptAndResponse(
@@ -130,6 +140,7 @@ class ChatCodingService(var actionType: ChatActionType, val project: Project) {
130140

131141
funclearSession() {
132142
// recreate session to make sure the history is cleared
143+
stop()
133144
llmProvider=LlmFactory.create(project)
134145
}
135146

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp