Skip to content

Conversation

@shivarag200701
Copy link

Description

This PR implements a comprehensive rate limiting system for LLM requests to prevent API rate limit errors and control costs, which addresses [Feature] Add rate limit slider #646)

🚀 Features Added

  • RateLimiterService: Implements sliding window rate limiting feature that only allows the required number of API calls per Minute
  • Settings Integration: Adds maxRequestsPerMinute setting to control request frequency
  • User Notifications: Shows wait times when rate limits are reached
  • Automatic Cleanup: Removes old timestamps to maintain accurate counting
  • Test Method: Includes testRateLimit() for debugging and verification which constinously send calls to LLMMessageService(The code was commented out)

�� Technical Details

  • Uses sliding window approach (1-minute window)
  • Integrates with existing LLMMessageService
  • Handles concurrent requests properly

📝 Files Changed

  • src/vs/workbench/contrib/void/common/rateLimiterService.ts (new)
  • src/vs/workbench/contrib/void/browser/rateLimiter.contribution.ts (new)
  • src/vs/workbench/contrib/void/common/sendLLMMessageService.ts (modified)
  • src/vs/workbench/contrib/void/browser/autocompleteService.ts (modified)
  • src/vs/workbench/contrib/void/browser/chatThreadService.ts (modified)
  • src/vs/workbench/contrib/void/browser/editCodeService.ts (modified)
  • src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx (modified)
  • src/vs/workbench/contrib/void/browser/voidSCMService.ts (modified)
  • src/vs/workbench/contrib/void/browser/void.contribution.ts (modified)
  • src/vs/workbench/contrib/void/common/voidSettingsTypes.ts (modified)

�� Testing

  • Rate limiter properly enforces limits
  • User notifications work correctly
  • Sliding window cleanup functions as expected
  • Test method validates functionality
  • EdgeCases also work well

⚙️ Configuration

Users can configure the rate limit via:

{
    "void.globalSettings.maxRequestsPerMinute": 60
}

🔍 Screenshots

Slider
Screenshot 2025-06-20 at 4 40 39 PM

Notifications
Screenshot 2025-06-20 at 4 45 40 PM

- Add RateLimiterService with sliding window approach
- Integrate rate limiting into LLMMessageService
- Add maxRequestsPerMinute setting
- Add user notifications for rate limit waits
- Add test method for rate limiting functionality
@llaravell
Copy link

nice thanks man. this is very helpful

@shivarag200701
Copy link
Author

nice thanks man. this is very helpful

Thanks for that, But the , no one has reviewed it yet:((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants