合并 - #2287
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis PR introduces channel-level rate limiting with per-model configuration. It adds Redis-backed rate limit enforcement (RPM/TPM/RPD), a monitoring endpoint for viewing real-time usage, backend rate limit checks in the relay loop, and a complete admin UI for managing and displaying rate limit metrics. Changes
Sequence DiagramsequenceDiagram
actor Admin as Admin
participant UI as Frontend UI
participant API as Backend API
participant Redis as Redis
participant DB as Database
rect rgb(220, 240, 255)
note over Admin,DB: Rate Limit Check During Relay
end
API->>API: Relay receives request
API->>DB: Fetch channel & model rate limits
API->>API: Determine RPM, TPM, RPD limits
API->>Redis: CheckChannelRateLimit(channel, model)
alt Limit Exceeded
Redis-->>API: Error (RPM/TPM/RPD exceeded)
API->>API: Return ChannelRateLimited error
else Limit OK
Redis-->>API: OK
API->>API: Forward request downstream
API->>Redis: RecordChannelRateLimit(usage)
Redis->>Redis: Log timestamp/counter
API-->>API: Return response
end
rect rgb(240, 255, 240)
note over Admin,DB: Rate Limit Monitoring Flow
end
Admin->>UI: Open rate limit monitor
UI->>API: GET /api/channel/:id/monitor
API->>DB: Fetch channel & models
API->>Redis: Read current RPM/TPM/RPD
Redis-->>API: Usage counters
API->>API: Calculate aggregates per model
API-->>UI: ChannelMonitorData (current/limits)
UI->>UI: Render progress bars & metrics
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Areas requiring extra attention:
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (21)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
合并
Summary by CodeRabbit
Release Notes
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.