mirror of
https://github.com/TheSmallHanCat/sora2api.git
synced 2026-02-15 19:14:44 +08:00
feat: 普号增加25s普通视频、增加pro系列高清模型、统一模型名字、过载不再计入错误禁用计数
This commit is contained in:
@@ -17,13 +17,14 @@ class LoadBalancer:
|
||||
# Use image timeout from config as lock timeout
|
||||
self.token_lock = TokenLock(lock_timeout=config.image_timeout)
|
||||
|
||||
async def select_token(self, for_image_generation: bool = False, for_video_generation: bool = False) -> Optional[Token]:
|
||||
async def select_token(self, for_image_generation: bool = False, for_video_generation: bool = False, require_pro: bool = False) -> Optional[Token]:
|
||||
"""
|
||||
Select a token using random load balancing
|
||||
|
||||
Args:
|
||||
for_image_generation: If True, only select tokens that are not locked for image generation and have image_enabled=True
|
||||
for_video_generation: If True, filter out tokens with Sora2 quota exhausted (sora2_cooldown_until not expired), tokens that don't support Sora2, and tokens with video_enabled=False
|
||||
require_pro: If True, only select tokens with ChatGPT Pro subscription (plan_type="chatgpt_pro")
|
||||
|
||||
Returns:
|
||||
Selected token or None if no available tokens
|
||||
@@ -56,6 +57,13 @@ class LoadBalancer:
|
||||
if not active_tokens:
|
||||
return None
|
||||
|
||||
# Filter for Pro tokens if required
|
||||
if require_pro:
|
||||
pro_tokens = [token for token in active_tokens if token.plan_type == "chatgpt_pro"]
|
||||
if not pro_tokens:
|
||||
return None
|
||||
active_tokens = pro_tokens
|
||||
|
||||
# If for video generation, filter out tokens with Sora2 quota exhausted and tokens without Sora2 support
|
||||
if for_video_generation:
|
||||
from datetime import datetime
|
||||
|
||||
Reference in New Issue
Block a user