Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): make ALL_PLANS a display-only pricing catalog (#45115)

yyh97c97f069609
diff --git a/web/__tests__/billing/billing-integration.test.tsx b/web/__tests__/billing/billing-integration.test.tsx
index 7d5f9c4bc82..6aaa6ff70df 100644
--- a/web/__tests__/billing/billing-integration.test.tsx
+++ b/web/__tests__/billing/billing-integration.test.tsx
@@ -14,7 +14,6 @@ import AnnotationFull from '@/app/components/billing/annotation-full'
import AnnotationFullModal from '@/app/components/billing/annotation-full/modal'
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import Billing from '@/app/components/billing/billing-page'
-import { NUM_INFINITE } from '@/app/components/billing/config'
import PlanComp from '@/app/components/billing/plan'
import { PlanUpgradeModal } from '@/app/components/billing/plan-upgrade-modal'
import PriorityLabel from '@/app/components/billing/priority-label'
@@ -158,7 +157,7 @@ describe('Billing Page + Plan Integration', () => {
it('should show "unlimited" for infinite quotas (professional API rate limit)', () => {
setupBilling({
billing: { subscription: { plan: 'professional' } },
- api_rate_limit: { limit: NUM_INFINITE },
+ api_rate_limit: { limit: -1 },
})
render(<PlanComp loc="test" />)
diff --git a/web/app/components/billing/config.ts b/web/app/components/billing/config.ts
index feaf15c2e92..726ba9e6198 100644
--- a/web/app/components/billing/config.ts
+++ b/web/app/components/billing/config.ts
@@ -1,9 +1,6 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
import type { PlanInfo } from '@/app/components/billing/type'
-const supportModelProviders = 'OpenAI/Anthropic/Llama2/Azure OpenAI/Hugging Face/Replicate'
-
-export const NUM_INFINITE = -1
export const contactSalesUrl = 'https://vikgc6bnu1s.typeform.com/dify-business'
export const SELF_HOSTED_PLAN_URLS = {
community: 'https://github.com/langgenius/dify',
@@ -13,59 +10,56 @@ export const SELF_HOSTED_PLAN_URLS = {
export type SelfHostedPlan = keyof typeof SELF_HOSTED_PLAN_URLS
-export const ALL_PLANS: Record<CloudPlan, PlanInfo> = {
+export const ALL_PLANS = {
sandbox: {
level: 1,
price: 0,
- modelProviders: supportModelProviders,
- teamWorkspace: 1,
+ messageRequest: { count: 200, perMonth: false },
teamMembers: 1,
buildApps: 5,
documents: 50,
vectorSpace: '50MB',
- documentsUploadQuota: 0,
documentsRequestQuota: 10,
- apiRateLimit: 5000,
documentProcessingPriority: 'standard',
- messageRequest: 200,
- triggerEvents: 3000,
+ triggerEvents: { count: 3000, perMonth: false },
+ startNodes: 2,
+ workflowExecution: 'standard',
annotatedResponse: 10,
logHistory: 30,
+ apiRateLimit: 5000,
},
professional: {
level: 2,
price: 59,
- modelProviders: supportModelProviders,
- teamWorkspace: 1,
+ messageRequest: { count: 5000, perMonth: true },
teamMembers: 3,
buildApps: 50,
documents: 500,
vectorSpace: '5GB',
- documentsUploadQuota: 0,
documentsRequestQuota: 100,
- apiRateLimit: NUM_INFINITE,
documentProcessingPriority: 'priority',
- messageRequest: 5000,
- triggerEvents: 20000,
+ triggerEvents: { count: 20000, perMonth: true },
+ startNodes: 'unlimited',
+ workflowExecution: 'faster',
annotatedResponse: 2000,
- logHistory: NUM_INFINITE,
+ logHistory: 'unlimited',
+ apiRateLimit: 'unlimited',
},
team: {
level: 3,
price: 159,
- modelProviders: supportModelProviders,
- teamWorkspace: 1,
+ messageRequest: { count: 10000, perMonth: true },
teamMembers: 50,
buildApps: 200,
documents: 1000,
vectorSpace: '20GB',
- documentsUploadQuota: 0,
documentsRequestQuota: 1000,
- apiRateLimit: NUM_INFINITE,
documentProcessingPriority: 'top-priority',
- messageRequest: 10000,
- triggerEvents: NUM_INFINITE,
+ triggerEvents: 'unlimited',
+ startNodes: 'unlimited',
+ workflowExecution: 'priority',
annotatedResponse: 5000,
- logHistory: NUM_INFINITE,
+ logHistory: 'unlimited',
+ apiRateLimit: 'unlimited',
},
-}
+} satisfies Record<CloudPlan, PlanInfo>
diff --git a/web/app/components/billing/pricing/plans/cloud-plan-item/list/index.tsx b/web/app/components/billing/pricing/plans/cloud-plan-item/list/index.tsx
index dbac701af20..2ea062ffcbe 100644
--- a/web/app/components/billing/pricing/plans/cloud-plan-item/list/index.tsx
+++ b/web/app/components/billing/pricing/plans/cloud-plan-item/list/index.tsx
@@ -1,141 +1,142 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
+import type { TFunction } from 'i18next'
+import type { PlanInfo } from '../../../../type'
import { Separator } from '@langgenius/dify-ui/separator'
+import { Fragment } from 'react'
import { useTranslation } from 'react-i18next'
-import { ALL_PLANS, NUM_INFINITE } from '../../../../config'
+import { ALL_PLANS } from '../../../../config'
import { CloudPlanFeature } from './item'
-export function CloudPlanFeatures({ plan }: { plan: CloudPlan }) {
- const { t } = useTranslation(['billing'])
- const isFreePlan = plan === 'sandbox'
- const planInfo = ALL_PLANS[plan]
+type PlanFeature = {
+ id: string
+ label: string
+ description?: string
+}
- return (
- <div className="flex flex-col gap-y-2.5 p-6">
- <CloudPlanFeature
- label={
- isFreePlan
- ? t(($) => $['plansCommon.messageRequest.title'], {
- ns: 'billing',
- count: planInfo.messageRequest,
- })
- : t(($) => $['plansCommon.messageRequest.titlePerMonth'], {
- ns: 'billing',
- count: planInfo.messageRequest,
- })
- }
- description={t(($) => $['plansCommon.messageRequest.tooltip'], { ns: 'billing' }) as string}
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.teamWorkspace'], {
- ns: 'billing',
- count: planInfo.teamWorkspace,
- })}
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.teamMember'], {
- ns: 'billing',
- count: planInfo.teamMembers,
- })}
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.buildApps'], { ns: 'billing', count: planInfo.buildApps })}
- />
- <Separator className="my-2 from-divider-accent" variant="gradient" />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.documents'], { ns: 'billing', count: planInfo.documents })}
- description={t(($) => $['plansCommon.documentsTooltip'], { ns: 'billing' }) as string}
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.vectorSpace'], {
- ns: 'billing',
- size: planInfo.vectorSpace,
- })}
- description={t(($) => $['plansCommon.vectorSpaceTooltip'], { ns: 'billing' }) as string}
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.documentsRequestQuota'], {
- ns: 'billing',
+function getPlanFeatureGroups(planInfo: PlanInfo, t: TFunction<['billing']>): PlanFeature[][] {
+ const { messageRequest, triggerEvents, startNodes, workflowExecution, logHistory, apiRateLimit } =
+ planInfo
+
+ return [
+ [
+ {
+ id: 'messageRequest',
+ label: messageRequest.perMonth
+ ? t(($) => $['plansCommon.messageRequest.titlePerMonth'], {
+ count: messageRequest.count,
+ })
+ : t(($) => $['plansCommon.messageRequest.title'], { count: messageRequest.count }),
+ description: t(($) => $['plansCommon.messageRequest.tooltip']),
+ },
+ { id: 'teamWorkspace', label: t(($) => $['plansCommon.teamWorkspace'], { count: 1 }) },
+ {
+ id: 'teamMembers',
+ label: t(($) => $['plansCommon.teamMember'], { count: planInfo.teamMembers }),
+ },
+ {
+ id: 'buildApps',
+ label: t(($) => $['plansCommon.buildApps'], { count: planInfo.buildApps }),
+ },
+ ],
+ [
+ {
+ id: 'documents',
+ label: t(($) => $['plansCommon.documents'], { count: planInfo.documents }),
+ description: t(($) => $['plansCommon.documentsTooltip']),
+ },
+ {
+ id: 'vectorSpace',
+ label: t(($) => $['plansCommon.vectorSpace'], { size: planInfo.vectorSpace }),
+ description: t(($) => $['plansCommon.vectorSpaceTooltip']),
+ },
+ {
+ id: 'documentsRequestQuota',
+ label: t(($) => $['plansCommon.documentsRequestQuota'], {
count: planInfo.documentsRequestQuota,
- })}
- description={t(($) => $['plansCommon.documentsRequestQuotaTooltip'], { ns: 'billing' })}
- />
- <CloudPlanFeature
- label={[
- t(($) => $[`plansCommon.priority.${planInfo.documentProcessingPriority}`], {
- ns: 'billing',
- }),
- t(($) => $['plansCommon.documentProcessingPriority'], { ns: 'billing' }),
- ].join('')}
- />
- <Separator className="my-2 from-divider-accent" variant="gradient" />
- <CloudPlanFeature
- label={
- planInfo.triggerEvents === NUM_INFINITE
- ? t(($) => $['plansCommon.triggerEvents.unlimited'], { ns: 'billing' })
- : plan === 'sandbox'
- ? t(($) => $['plansCommon.triggerEvents.sandbox'], {
- ns: 'billing',
- count: planInfo.triggerEvents,
- })
- : t(($) => $['plansCommon.triggerEvents.professional'], {
- ns: 'billing',
- count: planInfo.triggerEvents,
+ }),
+ description: t(($) => $['plansCommon.documentsRequestQuotaTooltip']),
+ },
+ {
+ id: 'documentProcessingPriority',
+ label: [
+ t(($) => $[`plansCommon.priority.${planInfo.documentProcessingPriority}`]),
+ t(($) => $['plansCommon.documentProcessingPriority']),
+ ].join(''),
+ },
+ ],
+ [
+ {
+ id: 'triggerEvents',
+ label:
+ triggerEvents === 'unlimited'
+ ? t(($) => $['plansCommon.triggerEvents.unlimited'])
+ : triggerEvents.perMonth
+ ? t(($) => $['plansCommon.triggerEvents.professional'], {
+ count: triggerEvents.count,
})
- }
- description={t(($) => $['plansCommon.triggerEvents.tooltip'], { ns: 'billing' }) as string}
- />
- <CloudPlanFeature
- label={
- plan === 'sandbox'
- ? t(($) => $['plansCommon.startNodes.limited'], { ns: 'billing', count: 2 })
- : t(($) => $['plansCommon.startNodes.unlimited'], { ns: 'billing' })
- }
- />
- <CloudPlanFeature
- label={
- plan === 'sandbox'
- ? t(($) => $['plansCommon.workflowExecution.standard'], { ns: 'billing' })
- : plan === 'professional'
- ? t(($) => $['plansCommon.workflowExecution.faster'], { ns: 'billing' })
- : t(($) => $['plansCommon.workflowExecution.priority'], { ns: 'billing' })
- }
- description={
- t(($) => $['plansCommon.workflowExecution.tooltip'], { ns: 'billing' }) as string
- }
- />
- <Separator className="my-2 from-divider-accent" variant="gradient" />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.annotatedResponse.title'], {
- ns: 'billing',
+ : t(($) => $['plansCommon.triggerEvents.sandbox'], { count: triggerEvents.count }),
+ description: t(($) => $['plansCommon.triggerEvents.tooltip']),
+ },
+ {
+ id: 'startNodes',
+ label:
+ startNodes === 'unlimited'
+ ? t(($) => $['plansCommon.startNodes.unlimited'])
+ : t(($) => $['plansCommon.startNodes.limited'], { count: startNodes }),
+ },
+ {
+ id: 'workflowExecution',
+ label: t(($) => $[`plansCommon.workflowExecution.${workflowExecution}`]),
+ description: t(($) => $['plansCommon.workflowExecution.tooltip']),
+ },
+ ],
+ [
+ {
+ id: 'annotatedResponse',
+ label: t(($) => $['plansCommon.annotatedResponse.title'], {
count: planInfo.annotatedResponse,
- })}
- description={
- t(($) => $['plansCommon.annotatedResponse.tooltip'], { ns: 'billing' }) as string
- }
- />
- <CloudPlanFeature
- label={t(($) => $['plansCommon.logsHistory'], {
- ns: 'billing',
+ }),
+ description: t(($) => $['plansCommon.annotatedResponse.tooltip']),
+ },
+ {
+ id: 'logHistory',
+ label: t(($) => $['plansCommon.logsHistory'], {
days:
- planInfo.logHistory === NUM_INFINITE
- ? (t(($) => $['plansCommon.unlimited'], { ns: 'billing' }) as string)
- : `${planInfo.logHistory} ${t(($) => $['plansCommon.days'], { ns: 'billing' })}`,
- })}
- />
- <CloudPlanFeature
- label={
- planInfo.apiRateLimit === NUM_INFINITE
- ? t(($) => $['plansCommon.unlimitedApiRate'], { ns: 'billing' })
- : `${t(($) => $['plansCommon.apiRateLimitUnit'], { ns: 'billing', count: planInfo.apiRateLimit })} ${t(($) => $['plansCommon.apiRateLimit'], { ns: 'billing' })}/${t(($) => $['plansCommon.month'], { ns: 'billing' })}`
- }
- description={
- planInfo.apiRateLimit === NUM_INFINITE
- ? undefined
- : (t(($) => $['plansCommon.apiRateLimitTooltip'], { ns: 'billing' }) as string)
- }
- />
- <Separator className="my-2 from-divider-accent" variant="gradient" />
- <CloudPlanFeature label={t(($) => $['plansCommon.modelProviders'], { ns: 'billing' })} />
+ logHistory === 'unlimited'
+ ? t(($) => $['plansCommon.unlimited'])
+ : `${logHistory} ${t(($) => $['plansCommon.days'])}`,
+ }),
+ },
+ apiRateLimit === 'unlimited'
+ ? { id: 'apiRateLimit', label: t(($) => $['plansCommon.unlimitedApiRate']) }
+ : {
+ id: 'apiRateLimit',
+ label: `${t(($) => $['plansCommon.apiRateLimitUnit'], { count: apiRateLimit })} ${t(($) => $['plansCommon.apiRateLimit'])}/${t(($) => $['plansCommon.month'])}`,
+ description: t(($) => $['plansCommon.apiRateLimitTooltip']),
+ },
+ ],
+ [{ id: 'modelProviders', label: t(($) => $['plansCommon.modelProviders']) }],
+ ]
+}
+
+export function CloudPlanFeatures({ plan }: { plan: CloudPlan }) {
+ const { t } = useTranslation(['billing'])
+ const featureGroups = getPlanFeatureGroups(ALL_PLANS[plan], t)
+
+ return (
+ <div className="flex flex-col gap-y-2.5 p-6">
+ {featureGroups.map((features, groupIndex) => (
+ <Fragment key={features[0]!.id}>
+ {groupIndex > 0 && <Separator className="my-2 from-divider-accent" variant="gradient" />}
+ {features.map((feature) => (
+ <CloudPlanFeature
+ key={feature.id}
+ label={feature.label}
+ description={feature.description}
+ />
+ ))}
+ </Fragment>
+ ))}
</div>
)
}
diff --git a/web/app/components/billing/type.ts b/web/app/components/billing/type.ts
index 6adddc29f0f..3278ab822f1 100644
--- a/web/app/components/billing/type.ts
+++ b/web/app/components/billing/type.ts
@@ -1,20 +1,25 @@
type DocumentProcessingPriority = 'standard' | 'priority' | 'top-priority'
+type WorkflowExecutionSpeed = 'standard' | 'faster' | 'priority'
+
+type PlanQuota = {
+ count: number
+ perMonth: boolean
+}
export type PlanInfo = {
level: number
price: number
- modelProviders: string
- teamWorkspace: number
+ messageRequest: PlanQuota
teamMembers: number
buildApps: number
documents: number
vectorSpace: string
- documentsUploadQuota: number
documentsRequestQuota: number
- apiRateLimit: number
documentProcessingPriority: DocumentProcessingPriority
- logHistory: number
- messageRequest: number
- triggerEvents: number
+ triggerEvents: PlanQuota | 'unlimited'
+ startNodes: number | 'unlimited'
+ workflowExecution: WorkflowExecutionSpeed
annotatedResponse: number
+ logHistory: number | 'unlimited'
+ apiRateLimit: number | 'unlimited'
}
diff --git a/web/app/components/billing/usage-info/vector-space-info.tsx b/web/app/components/billing/usage-info/vector-space-info.tsx
index 6d98a99c5ee..2e6686e51d1 100644
--- a/web/app/components/billing/usage-info/vector-space-info.tsx
+++ b/web/app/components/billing/usage-info/vector-space-info.tsx
@@ -6,15 +6,11 @@ import { useTranslation } from 'react-i18next'
import { consoleQuery } from '@/service/console'
import { getVectorSpaceQuota } from '../quota'
import UsageInfo from '../usage-info'
-import { getPlanVectorSpaceLimitMB } from '../utils'
type Props = Readonly<{
className?: string
}>
-// Storage threshold in MB - usage below this shows as "< 50 MB"
-const STORAGE_THRESHOLD_MB = getPlanVectorSpaceLimitMB('sandbox')
-
const VectorSpaceInfo: FC<Props> = ({ className }) => {
const { t } = useTranslation(['billing'])
const [{ data: plan }, { data: vectorSpace }] = useSuspenseQueries({
@@ -36,7 +32,7 @@ const VectorSpaceInfo: FC<Props> = ({ className }) => {
unit="MB"
unitPosition="inline"
storageMode
- storageThreshold={STORAGE_THRESHOLD_MB}
+ storageThreshold={50}
storageTooltip={t(($) => $['usagePage.storageThresholdTooltip'], { ns: 'billing' }) as string}
isSandboxPlan={plan === 'sandbox'}
usageUnknown={vectorSpace.usage_unknown}
diff --git a/web/app/components/billing/utils/__tests__/index.spec.ts b/web/app/components/billing/utils/__tests__/index.spec.ts
deleted file mode 100644
index bacd8d3b6b1..00000000000
--- a/web/app/components/billing/utils/__tests__/index.spec.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { parseVectorSpaceToMB } from '../index'
-
-describe('billing utils', () => {
- it.each([
- ['50MB', 50],
- ['5GB', 5120],
- ['50mb', 50],
- ['5gb', 5120],
- ['50', 0],
- ['50TB', 0],
- ])('converts vector storage %s to %i MB', (value, expected) => {
- expect(parseVectorSpaceToMB(value)).toBe(expected)
- })
-})
diff --git a/web/app/components/billing/utils/index.ts b/web/app/components/billing/utils/index.ts
deleted file mode 100644
index 7eb51998db0..00000000000
--- a/web/app/components/billing/utils/index.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
-import { ALL_PLANS } from '@/app/components/billing/config'
-
-/**
- * Parse vectorSpace string from ALL_PLANS config and convert to MB
- * @example "50MB" -> 50, "5GB" -> 5120, "20GB" -> 20480
- */
-export const parseVectorSpaceToMB = (vectorSpace: string): number => {
- const match = /^(\d+)(MB|GB)$/i.exec(vectorSpace)
- if (!match) return 0
-
- const value = Number.parseInt(match[1]!, 10)
- const unit = match[2]!.toUpperCase()
-
- return unit === 'GB' ? value * 1024 : value
-}
-
-/**
- * Get the vector space limit in MB for a given plan type from ALL_PLANS config
- */
-export const getPlanVectorSpaceLimitMB = (planType: CloudPlan): number => {
- return parseVectorSpaceToMB(ALL_PLANS[planType].vectorSpace)
-}