mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-09 11:01:22 +00:00
feat: use debouncing for code completions
This commit is contained in:
parent
620226ff1d
commit
e821ff9403
1 changed files with 9 additions and 2 deletions
|
|
@ -28,8 +28,11 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.sse.EventSource
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
||||
class CodeGPTInlineCompletionProvider : InlineCompletionProvider {
|
||||
class CodeGPTInlineCompletionProvider : DebouncedInlineCompletionProvider() {
|
||||
companion object {
|
||||
private val logger = thisLogger()
|
||||
}
|
||||
|
|
@ -39,7 +42,7 @@ class CodeGPTInlineCompletionProvider : InlineCompletionProvider {
|
|||
override val id: InlineCompletionProviderID
|
||||
get() = InlineCompletionProviderID("CodeGPTInlineCompletionProvider")
|
||||
|
||||
override suspend fun getSuggestion(request: InlineCompletionRequest): InlineCompletionSuggestion {
|
||||
override suspend fun getSuggestionDebounced(request: InlineCompletionRequest): InlineCompletionSuggestion {
|
||||
val editor = request.editor
|
||||
val project = editor.project
|
||||
if (project == null) {
|
||||
|
|
@ -112,6 +115,10 @@ class CodeGPTInlineCompletionProvider : InlineCompletionProvider {
|
|||
})
|
||||
}
|
||||
|
||||
override suspend fun getDebounceDelay(request: InlineCompletionRequest): Duration {
|
||||
return 600.toDuration(DurationUnit.MILLISECONDS)
|
||||
}
|
||||
|
||||
override fun isEnabled(event: InlineCompletionEvent): Boolean {
|
||||
val selectedService = GeneralSettings.getSelectedService()
|
||||
val codeCompletionsEnabled = when (selectedService) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue