MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / checkPredictions

Function checkPredictions

packages/server/src/utils/quotaUsage.ts:128–145  ·  view source on GitHub ↗
(orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager)

Source from the content-addressed store, hash-verified

126}
127
128export const checkPredictions = async (orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager) => {
129 if (!usageCacheManager || !subscriptionId) return
130
131 const currentPredictions: number = (await usageCacheManager.get(`predictions:${orgId}`)) || 0
132
133 const quotas = await usageCacheManager.getQuotas(subscriptionId)
134 const predictionsLimit = quotas[LICENSE_QUOTAS.PREDICTIONS_LIMIT]
135 if (predictionsLimit === -1) return
136
137 if (currentPredictions >= predictionsLimit) {
138 throw new InternalFlowiseError(StatusCodes.PAYMENT_REQUIRED, 'Predictions limit exceeded')
139 }
140
141 return {
142 usage: currentPredictions,
143 limit: predictionsLimit
144 }
145}
146
147// Storage does not renew per month nor do we store the total size in database, so we just store the total size in cache
148export const updateStorageUsage = (orgId: string, _: string = '', totalSize: number, usageCacheManager?: UsageCacheManager) => {

Callers 2

utilBuildChatflowFunction · 0.90
_executeAgentflowFunction · 0.90

Calls 2

getQuotasMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected