mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-19 19:46:55 +08:00
Revert "refactor(helper): 将LLMHelper StorageHelper的相关方法改为静态方法,移除实例调用"
This reverts commit 9f381b3c73.
This commit is contained in:
@@ -71,14 +71,13 @@ class LLMHelper:
|
||||
openai_proxy=settings.PROXY_HOST
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_models(provider: str, api_key: str, base_url: str = None) -> List[str]:
|
||||
def get_models(self, provider: str, api_key: str, base_url: str = None) -> List[str]:
|
||||
"""获取模型列表"""
|
||||
logger.info(f"获取 {provider} 模型列表...")
|
||||
if provider == "google":
|
||||
return LLMHelper._get_google_models(api_key)
|
||||
return self._get_google_models(api_key)
|
||||
else:
|
||||
return LLMHelper._get_openai_compatible_models(provider, api_key, base_url)
|
||||
return self._get_openai_compatible_models(provider, api_key, base_url)
|
||||
|
||||
@staticmethod
|
||||
def _get_google_models(api_key: str) -> List[str]:
|
||||
|
||||
@@ -20,23 +20,21 @@ class StorageHelper:
|
||||
return []
|
||||
return [schemas.StorageConf(**s) for s in storage_confs]
|
||||
|
||||
@staticmethod
|
||||
def get_storage(storage: str) -> Optional[schemas.StorageConf]:
|
||||
def get_storage(self, storage: str) -> Optional[schemas.StorageConf]:
|
||||
"""
|
||||
获取指定存储配置
|
||||
"""
|
||||
storagies = StorageHelper.get_storagies()
|
||||
storagies = self.get_storagies()
|
||||
for s in storagies:
|
||||
if s.type == storage:
|
||||
return s
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def set_storage(storage: str, conf: dict):
|
||||
def set_storage(self, storage: str, conf: dict):
|
||||
"""
|
||||
设置存储配置
|
||||
"""
|
||||
storagies = StorageHelper.get_storagies()
|
||||
storagies = self.get_storagies()
|
||||
if not storagies:
|
||||
storagies = [
|
||||
schemas.StorageConf(
|
||||
@@ -51,12 +49,11 @@ class StorageHelper:
|
||||
break
|
||||
SystemConfigOper().set(SystemConfigKey.Storages, [s.model_dump() for s in storagies])
|
||||
|
||||
@staticmethod
|
||||
def add_storage(storage: str, name: str, conf: dict):
|
||||
def add_storage(self, storage: str, name: str, conf: dict):
|
||||
"""
|
||||
添加存储配置
|
||||
"""
|
||||
storagies = StorageHelper.get_storagies()
|
||||
storagies = self.get_storagies()
|
||||
if not storagies:
|
||||
storagies = [
|
||||
schemas.StorageConf(
|
||||
@@ -73,12 +70,11 @@ class StorageHelper:
|
||||
))
|
||||
SystemConfigOper().set(SystemConfigKey.Storages, [s.model_dump() for s in storagies])
|
||||
|
||||
@staticmethod
|
||||
def reset_storage(storage: str):
|
||||
def reset_storage(self, storage: str):
|
||||
"""
|
||||
重置存储配置
|
||||
"""
|
||||
storagies = StorageHelper.get_storagies()
|
||||
storagies = self.get_storagies()
|
||||
for s in storagies:
|
||||
if s.type == storage:
|
||||
s.config = {}
|
||||
|
||||
Reference in New Issue
Block a user