feat: add configurable account selection strategies
Refactor account selection into a strategy pattern with three options: - Sticky: cache-optimized, stays on same account until rate-limited - Round-robin: load-balanced, rotates every request - Hybrid (default): smart distribution using health scores, token buckets, and LRU The hybrid strategy uses multiple signals for optimal account selection: health tracking for reliability, client-side token buckets for rate limiting, and LRU freshness to prefer rested accounts. Includes WebUI settings for strategy selection and unit tests. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,26 @@ const DEFAULT_CONFIG = {
|
||||
persistTokenCache: false,
|
||||
defaultCooldownMs: 10000, // 10 seconds
|
||||
maxWaitBeforeErrorMs: 120000, // 2 minutes
|
||||
modelMapping: {}
|
||||
modelMapping: {},
|
||||
// Account selection strategy configuration
|
||||
accountSelection: {
|
||||
strategy: 'hybrid', // 'sticky' | 'round-robin' | 'hybrid'
|
||||
// Hybrid strategy tuning (optional - sensible defaults)
|
||||
healthScore: {
|
||||
initial: 70, // Starting score for new accounts
|
||||
successReward: 1, // Points on successful request
|
||||
rateLimitPenalty: -10, // Points on rate limit
|
||||
failurePenalty: -20, // Points on other failures
|
||||
recoveryPerHour: 2, // Passive recovery rate
|
||||
minUsable: 50, // Minimum score to be selected
|
||||
maxScore: 100 // Maximum score cap
|
||||
},
|
||||
tokenBucket: {
|
||||
maxTokens: 50, // Maximum token capacity
|
||||
tokensPerMinute: 6, // Regeneration rate
|
||||
initialTokens: 50 // Starting tokens
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Config locations
|
||||
|
||||
Reference in New Issue
Block a user