refactor(services/tasks): Swtich to dify_config witch Pydantic (#6203)

This commit is contained in:
Waffle
2024-07-12 12:25:38 +08:00
committed by GitHub
parent d7a6f25c63
commit 7b225a5ab0
15 changed files with 51 additions and 53 deletions

View File

@@ -1,6 +1,6 @@
from flask import current_app
from pydantic import BaseModel, ConfigDict
from configs import dify_config
from services.billing_service import BillingService
from services.enterprise.enterprise_service import EnterpriseService
@@ -51,7 +51,7 @@ class FeatureService:
cls._fulfill_params_from_env(features)
if current_app.config['BILLING_ENABLED']:
if dify_config.BILLING_ENABLED:
cls._fulfill_params_from_billing_api(features, tenant_id)
return features
@@ -60,16 +60,16 @@ class FeatureService:
def get_system_features(cls) -> SystemFeatureModel:
system_features = SystemFeatureModel()
if current_app.config['ENTERPRISE_ENABLED']:
if dify_config.ENTERPRISE_ENABLED:
cls._fulfill_params_from_enterprise(system_features)
return system_features
@classmethod
def _fulfill_params_from_env(cls, features: FeatureModel):
features.can_replace_logo = current_app.config['CAN_REPLACE_LOGO']
features.model_load_balancing_enabled = current_app.config['MODEL_LB_ENABLED']
features.dataset_operator_enabled = current_app.config['DATASET_OPERATOR_ENABLED']
features.can_replace_logo = dify_config.CAN_REPLACE_LOGO
features.model_load_balancing_enabled = dify_config.MODEL_LB_ENABLED
features.dataset_operator_enabled = dify_config.DATASET_OPERATOR_ENABLED
@classmethod
def _fulfill_params_from_billing_api(cls, features: FeatureModel, tenant_id: str):