Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -670,6 +670,21 @@ def make_request(payload, auth_manager, model_id):
|
|
| 670 |
retry_delay = 1
|
| 671 |
accounts_exhausted = False
|
| 672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
for _ in range(len(multi_auth_manager.auth_managers)): # 尝试所有可用的账号
|
| 674 |
auth_manager = multi_auth_manager.get_next_auth_manager(model_id)
|
| 675 |
if not auth_manager:
|
|
@@ -715,13 +730,15 @@ def make_request(payload, auth_manager, model_id):
|
|
| 715 |
# If we've exhausted all retries for this account, continue to the next account
|
| 716 |
continue
|
| 717 |
|
| 718 |
-
#
|
| 719 |
if accounts_exhausted:
|
| 720 |
-
logger.info("
|
| 721 |
try:
|
|
|
|
| 722 |
successful_accounts = register_bot.register_and_verify(5) # 注册5个账号
|
| 723 |
|
| 724 |
if successful_accounts:
|
|
|
|
| 725 |
# 重新初始化 multi_auth_manager
|
| 726 |
credentials = [(account['email'], account['password']) for account in successful_accounts]
|
| 727 |
multi_auth_manager = MultiAuthManager(credentials)
|
|
@@ -733,7 +750,7 @@ def make_request(payload, auth_manager, model_id):
|
|
| 733 |
raise Exception("Failed to register new accounts")
|
| 734 |
except Exception as e:
|
| 735 |
logger.error(f"自动注册过程发生错误: {e}")
|
| 736 |
-
raise Exception("Failed to make request after trying all accounts")
|
| 737 |
|
| 738 |
raise Exception("Failed to make request after trying all accounts")
|
| 739 |
|
|
|
|
| 670 |
retry_delay = 1
|
| 671 |
accounts_exhausted = False
|
| 672 |
|
| 673 |
+
logger.info(f"尝试发送请求,模型:{model_id}")
|
| 674 |
+
|
| 675 |
+
# 首先检查 multi_auth_manager 是否存在
|
| 676 |
+
if not multi_auth_manager:
|
| 677 |
+
logger.error("MultiAuthManager 不存在,尝试重新初始化")
|
| 678 |
+
credentials = get_auth_credentials()
|
| 679 |
+
if not credentials:
|
| 680 |
+
logger.error("无法获取凭据,尝试注册新账号")
|
| 681 |
+
successful_accounts = register_bot.register_and_verify(5)
|
| 682 |
+
if successful_accounts:
|
| 683 |
+
credentials = [(account['email'], account['password']) for account in successful_accounts]
|
| 684 |
+
multi_auth_manager = MultiAuthManager(credentials)
|
| 685 |
+
else:
|
| 686 |
+
raise Exception("无法注册新账号")
|
| 687 |
+
|
| 688 |
for _ in range(len(multi_auth_manager.auth_managers)): # 尝试所有可用的账号
|
| 689 |
auth_manager = multi_auth_manager.get_next_auth_manager(model_id)
|
| 690 |
if not auth_manager:
|
|
|
|
| 730 |
# If we've exhausted all retries for this account, continue to the next account
|
| 731 |
continue
|
| 732 |
|
| 733 |
+
# 如果所有账号都被耗尽,强制注册新账号
|
| 734 |
if accounts_exhausted:
|
| 735 |
+
logger.info("所有账号已耗尽,强制尝试注册新账号")
|
| 736 |
try:
|
| 737 |
+
# 直接调用注册方法
|
| 738 |
successful_accounts = register_bot.register_and_verify(5) # 注册5个账号
|
| 739 |
|
| 740 |
if successful_accounts:
|
| 741 |
+
logger.info(f"成功注册 {len(successful_accounts)} 个新账号")
|
| 742 |
# 重新初始化 multi_auth_manager
|
| 743 |
credentials = [(account['email'], account['password']) for account in successful_accounts]
|
| 744 |
multi_auth_manager = MultiAuthManager(credentials)
|
|
|
|
| 750 |
raise Exception("Failed to register new accounts")
|
| 751 |
except Exception as e:
|
| 752 |
logger.error(f"自动注册过程发生错误: {e}")
|
| 753 |
+
raise Exception("Failed to make request after trying all accounts and registration")
|
| 754 |
|
| 755 |
raise Exception("Failed to make request after trying all accounts")
|
| 756 |
|