|
|
|
|
@ -35,7 +35,8 @@ class LicenseModel(BaseModel):
|
|
|
|
|
status: LicenseStatus = LicenseStatus.NONE
|
|
|
|
|
expired_at: str = ""
|
|
|
|
|
product_id: str = ""
|
|
|
|
|
available_workspaces: int = 0
|
|
|
|
|
workspaces: LimitationModel = LimitationModel(size=0, limit=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BrandingModel(BaseModel):
|
|
|
|
|
@ -58,7 +59,7 @@ class FeatureModel(BaseModel):
|
|
|
|
|
model_load_balancing_enabled: bool = False
|
|
|
|
|
dataset_operator_enabled: bool = False
|
|
|
|
|
webapp_copyright_enabled: bool = False
|
|
|
|
|
available_team_members: int = 0
|
|
|
|
|
workspace_members: LimitationModel = LimitationModel(size=0, limit=0)
|
|
|
|
|
|
|
|
|
|
# pydantic configs
|
|
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
@ -92,7 +93,7 @@ class FeatureService:
|
|
|
|
|
|
|
|
|
|
if dify_config.ENTERPRISE_ENABLED:
|
|
|
|
|
features.webapp_copyright_enabled = True
|
|
|
|
|
cls._fulfill_parms_from_license(features, tenant_id)
|
|
|
|
|
cls._fulfill_parms_from_license_info(features, tenant_id)
|
|
|
|
|
|
|
|
|
|
return features
|
|
|
|
|
|
|
|
|
|
@ -125,9 +126,10 @@ class FeatureService:
|
|
|
|
|
features.dataset_operator_enabled = dify_config.DATASET_OPERATOR_ENABLED
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _fulfill_parms_from_license(cls, features: FeatureModel, tenant_id: str):
|
|
|
|
|
def _fulfill_parms_from_license_info(cls, features: FeatureModel, tenant_id: str):
|
|
|
|
|
license_info = EnterpriseService.get_info(tenant_id)["License"]
|
|
|
|
|
features.available_team_members = license_info["availableTeamMembers"]
|
|
|
|
|
features.workspace_members.limit = license_info["workspaceMembers"]["limit"]
|
|
|
|
|
features.workspace_members.size = license_info["workspaceMembers"]["used"]
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _fulfill_params_from_billing_api(cls, features: FeatureModel, tenant_id: str):
|
|
|
|
|
@ -215,8 +217,6 @@ class FeatureService:
|
|
|
|
|
if "productId" in license_info:
|
|
|
|
|
features.license.product_id = license_info["productId"]
|
|
|
|
|
|
|
|
|
|
# if "availableTeamMembers" in license_info:
|
|
|
|
|
# features.license.available_team_members = license_info["availableTeamMembers"]
|
|
|
|
|
|
|
|
|
|
if "availableWorkspaces" in license_info:
|
|
|
|
|
features.license.available_workspaces = license_info["availableWorkspaces"]
|
|
|
|
|
if "workspaces" in license_info:
|
|
|
|
|
features.license.workspaces.limit = license_info["workspaces"]["limit"]
|
|
|
|
|
features.license.workspaces.size = license_info["workspaces"]["used"]
|
|
|
|
|
|