feat: introduce trigger functionality (#27644)

Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Yeuoly
2025-11-12 17:59:37 +08:00
committed by GitHub
parent ca7794305b
commit b76e17b25d
785 changed files with 41186 additions and 3725 deletions

View File

@@ -26,6 +26,7 @@ export const ALL_PLANS: Record<BasicPlan, PlanInfo> = {
apiRateLimit: 5000,
documentProcessingPriority: Priority.standard,
messageRequest: 200,
triggerEvents: 3000,
annotatedResponse: 10,
logHistory: 30,
},
@@ -43,6 +44,7 @@ export const ALL_PLANS: Record<BasicPlan, PlanInfo> = {
apiRateLimit: NUM_INFINITE,
documentProcessingPriority: Priority.priority,
messageRequest: 5000,
triggerEvents: 20000,
annotatedResponse: 2000,
logHistory: NUM_INFINITE,
},
@@ -60,6 +62,7 @@ export const ALL_PLANS: Record<BasicPlan, PlanInfo> = {
apiRateLimit: NUM_INFINITE,
documentProcessingPriority: Priority.topPriority,
messageRequest: 10000,
triggerEvents: NUM_INFINITE,
annotatedResponse: 5000,
logHistory: NUM_INFINITE,
},
@@ -74,6 +77,8 @@ export const defaultPlan = {
teamMembers: 1,
annotatedResponse: 1,
documentsUploadQuota: 0,
apiRateLimit: 0,
triggerEvents: 0,
},
total: {
documents: 50,
@@ -82,5 +87,7 @@ export const defaultPlan = {
teamMembers: 1,
annotatedResponse: 10,
documentsUploadQuota: 0,
apiRateLimit: ALL_PLANS.sandbox.apiRateLimit,
triggerEvents: ALL_PLANS.sandbox.triggerEvents,
},
}

View File

@@ -6,8 +6,10 @@ import { useRouter } from 'next/navigation'
import {
RiBook2Line,
RiFileEditLine,
RiFlashlightLine,
RiGraduationCapLine,
RiGroupLine,
RiSpeedLine,
} from '@remixicon/react'
import { Plan, SelfHostedPlan } from '../type'
import VectorSpaceInfo from '../usage-info/vector-space-info'
@@ -43,6 +45,8 @@ const PlanComp: FC<Props> = ({
usage,
total,
} = plan
const perMonthUnit = ` ${t('billing.usagePage.perMonth')}`
const triggerEventUnit = plan.type === Plan.sandbox ? undefined : perMonthUnit
const [showModal, setShowModal] = React.useState(false)
const { mutateAsync } = useEducationVerify()
@@ -119,6 +123,20 @@ const PlanComp: FC<Props> = ({
usage={usage.annotatedResponse}
total={total.annotatedResponse}
/>
<UsageInfo
Icon={RiFlashlightLine}
name={t('billing.usagePage.triggerEvents')}
usage={usage.triggerEvents}
total={total.triggerEvents}
unit={triggerEventUnit}
/>
<UsageInfo
Icon={RiSpeedLine}
name={t('billing.plansCommon.apiRateLimit')}
usage={usage.apiRateLimit}
total={total.apiRateLimit}
unit={perMonthUnit}
/>
</div>
<VerifyStateModal

View File

@@ -56,6 +56,31 @@ const List = ({
<Item
label={[t(`billing.plansCommon.priority.${planInfo.documentProcessingPriority}`), t('billing.plansCommon.documentProcessingPriority')].join('')}
/>
<Item
label={
planInfo.triggerEvents === NUM_INFINITE
? t('billing.plansCommon.triggerEvents.unlimited')
: plan === Plan.sandbox
? t('billing.plansCommon.triggerEvents.sandbox', { count: planInfo.triggerEvents })
: t('billing.plansCommon.triggerEvents.professional', { count: planInfo.triggerEvents })
}
/>
<Item
label={
plan === Plan.sandbox
? t('billing.plansCommon.workflowExecution.standard')
: plan === Plan.professional
? t('billing.plansCommon.workflowExecution.faster')
: t('billing.plansCommon.workflowExecution.priority')
}
/>
<Item
label={
plan === Plan.sandbox
? t('billing.plansCommon.startNodes.limited', { count: 2 })
: t('billing.plansCommon.startNodes.unlimited')
}
/>
<Divider bgStyle='gradient' />
<Item
label={t('billing.plansCommon.annotatedResponse.title', { count: planInfo.annotatedResponse })}

View File

@@ -27,6 +27,7 @@ export type PlanInfo = {
documentProcessingPriority: Priority
logHistory: number
messageRequest: number
triggerEvents: number
annotatedResponse: number
}
@@ -52,7 +53,7 @@ export type SelfHostedPlanInfo = {
annotatedResponse: number
}
export type UsagePlanInfo = Pick<PlanInfo, 'buildApps' | 'teamMembers' | 'annotatedResponse' | 'documentsUploadQuota'> & { vectorSpace: number }
export type UsagePlanInfo = Pick<PlanInfo, 'buildApps' | 'teamMembers' | 'annotatedResponse' | 'documentsUploadQuota' | 'apiRateLimit' | 'triggerEvents'> & { vectorSpace: number }
export enum DocumentProcessingPriority {
standard = 'standard',
@@ -87,6 +88,14 @@ export type CurrentPlanInfoBackend = {
size: number
limit: number // total. 0 means unlimited
}
api_rate_limit?: {
size: number
limit: number // total. 0 means unlimited
}
trigger_events?: {
size: number
limit: number // total. 0 means unlimited
}
docs_processing: DocumentProcessingPriority
can_replace_logo: boolean
model_load_balancing_enabled: boolean

View File

@@ -15,6 +15,7 @@ type Props = {
usage: number
total: number
unit?: string
unitPosition?: 'inline' | 'suffix'
}
const LOW = 50
@@ -27,7 +28,8 @@ const UsageInfo: FC<Props> = ({
tooltip,
usage,
total,
unit = '',
unit,
unitPosition = 'suffix',
}) => {
const { t } = useTranslation()
@@ -41,6 +43,12 @@ const UsageInfo: FC<Props> = ({
return 'bg-components-progress-error-progress'
})()
const isUnlimited = total === NUM_INFINITE
let totalDisplay: string | number = isUnlimited ? t('billing.plansCommon.unlimited') : total
if (!isUnlimited && unit && unitPosition === 'inline')
totalDisplay = `${total}${unit}`
const showUnit = !!unit && !isUnlimited && unitPosition === 'suffix'
return (
<div className={cn('flex flex-col gap-2 rounded-xl bg-components-panel-bg p-4', className)}>
<Icon className='h-4 w-4 text-text-tertiary' />
@@ -56,10 +64,17 @@ const UsageInfo: FC<Props> = ({
/>
)}
</div>
<div className='system-md-semibold flex items-center gap-1 text-text-primary'>
{usage}
<div className='system-md-regular text-text-quaternary'>/</div>
<div>{total === NUM_INFINITE ? t('billing.plansCommon.unlimited') : `${total}${unit}`}</div>
<div className='system-md-semibold flex items-center gap-1 text-text-primary'>
<div className='flex items-center gap-1'>
{usage}
<div className='system-md-regular text-text-quaternary'>/</div>
<div>{totalDisplay}</div>
</div>
{showUnit && (
<div className='system-xs-medium ml-auto text-text-tertiary'>
{unit}
</div>
)}
</div>
<ProgressBar
percent={percent}

View File

@@ -30,6 +30,7 @@ const VectorSpaceInfo: FC<Props> = ({
usage={usage.vectorSpace}
total={total.vectorSpace}
unit='MB'
unitPosition='inline'
/>
)
}

View File

@@ -1,5 +1,5 @@
import type { CurrentPlanInfoBackend } from '../type'
import { NUM_INFINITE } from '@/app/components/billing/config'
import { ALL_PLANS, NUM_INFINITE } from '@/app/components/billing/config'
const parseLimit = (limit: number) => {
if (limit === 0)
@@ -9,14 +9,23 @@ const parseLimit = (limit: number) => {
}
export const parseCurrentPlan = (data: CurrentPlanInfoBackend) => {
const planType = data.billing.subscription.plan
const planPreset = ALL_PLANS[planType]
const resolveLimit = (limit?: number, fallback?: number) => {
const value = limit ?? fallback ?? 0
return parseLimit(value)
}
return {
type: data.billing.subscription.plan,
type: planType,
usage: {
vectorSpace: data.vector_space.size,
buildApps: data.apps?.size || 0,
teamMembers: data.members.size,
annotatedResponse: data.annotation_quota_limit.size,
documentsUploadQuota: data.documents_upload_quota.size,
apiRateLimit: data.api_rate_limit?.size ?? 0,
triggerEvents: data.trigger_events?.size ?? 0,
},
total: {
vectorSpace: parseLimit(data.vector_space.limit),
@@ -24,6 +33,8 @@ export const parseCurrentPlan = (data: CurrentPlanInfoBackend) => {
teamMembers: parseLimit(data.members.limit),
annotatedResponse: parseLimit(data.annotation_quota_limit.limit),
documentsUploadQuota: parseLimit(data.documents_upload_quota.limit),
apiRateLimit: resolveLimit(data.api_rate_limit?.limit, planPreset?.apiRateLimit ?? NUM_INFINITE),
triggerEvents: resolveLimit(data.trigger_events?.limit, planPreset?.triggerEvents),
},
}
}