fix: seperate education fields from billing

This commit is contained in:
GareArc 2025-03-14 04:25:31 -04:00
parent 31934b46d9
commit 4b055595b3
3 changed files with 17 additions and 2 deletions

View File

@ -445,4 +445,7 @@ CREATE_TIDB_SERVICE_JOB_ENABLED=false
# Maximum number of submitted thread count in a ThreadPool for parallel node execution
MAX_SUBMIT_COUNT=100
# Lockout duration in seconds
LOGIN_LOCKOUT_DURATION=86400
LOGIN_LOCKOUT_DURATION=86400
# Education Identity
EDUCATION_ENABLED=false

View File

@ -844,6 +844,11 @@ class AccountConfig(BaseSettings):
default=5,
)
EDUCATION_ENABLED: bool = Field(
description="whether to enable education identity",
default=False,
)
class FeatureConfig(
# place the configs in alphabet order

View File

@ -18,6 +18,11 @@ class BillingModel(BaseModel):
subscription: SubscriptionModel = SubscriptionModel()
class EducationModel(BaseModel):
enabled: bool = False
is_activated: bool = False
class LimitationModel(BaseModel):
size: int = 0
limit: int = 0
@ -39,6 +44,7 @@ class LicenseModel(BaseModel):
class FeatureModel(BaseModel):
billing: BillingModel = BillingModel()
education: EducationModel = EducationModel()
members: LimitationModel = LimitationModel(size=0, limit=1)
apps: LimitationModel = LimitationModel(size=0, limit=10)
vector_space: LimitationModel = LimitationModel(size=0, limit=5)
@ -112,6 +118,7 @@ class FeatureService:
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
features.education.enabled = dify_config.EDUCATION_ENABLED
@classmethod
def _fulfill_params_from_billing_api(cls, features: FeatureModel, tenant_id: str):
@ -120,7 +127,7 @@ class FeatureService:
features.billing.enabled = billing_info["enabled"]
features.billing.subscription.plan = billing_info["subscription"]["plan"]
features.billing.subscription.interval = billing_info["subscription"]["interval"]
features.billing.subscription.education = billing_info["subscription"].get("education", False)
features.education.is_activated = billing_info["subscription"].get("education", False)
if "members" in billing_info:
features.members.size = billing_info["members"]["size"]