refactor: 适配配置管理器读取方式

This commit is contained in:
RockChinQ
2023-11-26 23:58:06 +08:00
parent 549a7eff7f
commit 3e17bbb90f
20 changed files with 147 additions and 112 deletions
+4 -3
View File
@@ -3,6 +3,8 @@ import logging
import openai
from ...utils import context
class RequestBase:
@@ -14,7 +16,6 @@ class RequestBase:
raise NotImplementedError
def _next_key(self):
import pkg.utils.context as context
switched, name = context.get_openai_manager().key_mgr.auto_switch()
logging.debug("切换api-key: switched={}, name={}".format(switched, name))
self.client.api_key = context.get_openai_manager().key_mgr.get_using_key()
@@ -22,12 +23,12 @@ class RequestBase:
def _req(self, **kwargs):
"""处理代理问题"""
logging.debug("请求接口参数: %s", str(kwargs))
import config
config = context.get_config_manager().data
ret = self.req_func(**kwargs)
logging.debug("接口请求返回:%s", str(ret))
if config.switch_strategy == 'active':
if config['switch_strategy'] == 'active':
self._next_key()
return ret