mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-10 03:59:43 +00:00
feat: disable code completions when rate limit exceeded
This commit is contained in:
parent
8dd74b3d84
commit
25d8835db1
1 changed files with 11 additions and 0 deletions
|
|
@ -2,11 +2,15 @@ package ee.carlrobert.codegpt.codecompletions
|
|||
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import ee.carlrobert.codegpt.CodeGPTKeys.IS_FETCHING_COMPLETION
|
||||
import ee.carlrobert.codegpt.CodeGPTKeys.REMAINING_EDITOR_COMPLETION
|
||||
import ee.carlrobert.codegpt.settings.GeneralSettings
|
||||
import ee.carlrobert.codegpt.settings.service.ServiceType
|
||||
import ee.carlrobert.codegpt.settings.service.codegpt.CodeGPTServiceSettings
|
||||
import ee.carlrobert.codegpt.ui.OverlayUtil.showNotification
|
||||
import ee.carlrobert.codegpt.util.StringUtil
|
||||
import ee.carlrobert.llm.client.openai.completion.ErrorDetails
|
||||
|
|
@ -70,6 +74,13 @@ abstract class CodeCompletionEventListener(
|
|||
}
|
||||
|
||||
override fun onError(error: ErrorDetails, ex: Throwable) {
|
||||
val isCodeGPTService = GeneralSettings.getSelectedService() == ServiceType.CODEGPT
|
||||
if (isCodeGPTService && "RATE_LIMIT_EXCEEDED" == error.code) {
|
||||
service<CodeGPTServiceSettings>().state
|
||||
.codeCompletionSettings
|
||||
.codeCompletionsEnabled = false
|
||||
}
|
||||
|
||||
if (ex.message == null || (ex.message != null && ex.message != "Canceled")) {
|
||||
showNotification(error.message, NotificationType.ERROR)
|
||||
logger.error(error.message, ex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue