mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-08-25 02:00:36 +08:00
refactor: 将MAX_FAILURES配置移至settings并更新KeyManager以使用该配置
This commit is contained in:
@@ -11,6 +11,7 @@ class Settings(BaseSettings):
|
||||
SHOW_SEARCH_LINK: bool = True
|
||||
SHOW_THINKING_PROCESS: bool = True
|
||||
AUTH_TOKEN: str = ""
|
||||
MAX_FAILURES: int = 3
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -2,6 +2,7 @@ import asyncio
|
||||
from itertools import cycle
|
||||
from typing import Dict
|
||||
from app.core.logger import get_key_manager_logger
|
||||
from app.core.config import settings
|
||||
|
||||
logger = get_key_manager_logger()
|
||||
|
||||
@@ -13,7 +14,7 @@ class KeyManager:
|
||||
self.key_cycle_lock = asyncio.Lock()
|
||||
self.failure_count_lock = asyncio.Lock()
|
||||
self.key_failure_counts: Dict[str, int] = {key: 0 for key in api_keys}
|
||||
self.MAX_FAILURES = 10
|
||||
self.MAX_FAILURES = settings.MAX_FAILURES
|
||||
|
||||
async def get_next_key(self) -> str:
|
||||
"""获取下一个API key"""
|
||||
|
||||
Reference in New Issue
Block a user