Spaces:
Paused
Paused
Commit ·
04c79ee
1
Parent(s): 8b27505
bug fixes
Browse files17 unmodified lines18192021222324252627282930318 unmodified lines40414243444546474849505112 unmodified lines6465666768697071727374757617 unmodified lines"""Get the total number of available Express API keys."""return len(self.express_keys)def _get_key_with_index(self, key: str, index: int) -> Tuple[str, int]:"""Return a tuple of (key, original_index) for logging purposes."""return (key, index)def get_random_express_key(self) -> Optional[Tuple[str, int]]:"""Get a random Express API key.Returns (key, original_index) tuple or None if no keys available."""if not self.express_keys:print("WARNING: No Express API keys available for selection.")8 unmodified lines# Return the first key (which is random due to shuffle)original_idx, key = indexed_keys[0]return self._get_key_with_index(key, original_idx)def get_roundrobin_express_key(self) -> Optional[Tuple[str, int]]:"""Get an Express API key using round-robin selection.Returns (key, original_index) tuple or None if no keys available."""if not self.express_keys:print("WARNING: No Express API keys available for selection.")12 unmodified lines# Move to next index for next callself.round_robin_index = (self.round_robin_index + 1) % len(self.express_keys)return self._get_key_with_index(key, original_idx)def get_express_api_key(self) -> Optional[Tuple[str, int]]:"""Get an Express API key based on the configured selection strategy.Checks ROUNDROBIN config and calls the appropriate method.Returns (key, original_index) tuple or None if no keys available."""if app_config.ROUNDROBIN:return self.get_roundrobin_express_key()17 unmodified lines181920212223242526278 unmodified lines36373839404142434445464712 unmodified lines6061626364656667686970717217 unmodified lines"""Get the total number of available Express API keys."""return len(self.express_keys)def get_random_express_key(self) -> Optional[Tuple[int, str]]:"""Get a random Express API key.Returns (original_index, key) tuple or None if no keys available."""if not self.express_keys:print("WARNING: No Express API keys available for selection.")8 unmodified lines# Return the first key (which is random due to shuffle)original_idx, key = indexed_keys[0]return (original_idx, key)def get_roundrobin_express_key(self) -> Optional[Tuple[int, str]]:"""Get an Express API key using round-robin selection.Returns (original_index, key) tuple or None if no keys available."""if not self.express_keys:print("WARNING: No Express API keys available for selection.")12 unmodified lines# Move to next index for next callself.round_robin_index = (self.round_robin_index + 1) % len(self.express_keys)return (original_idx, key)def get_express_api_key(self) -> Optional[Tuple[int, str]]:"""Get an Express API key based on the configured selection strategy.Checks ROUNDROBIN config and calls the appropriate method.Returns (original_index, key) tuple or None if no keys available."""if app_config.ROUNDROBIN:return self.get_roundrobin_express_key()
app/express_key_manager.py+8-12