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