Skip to content

Commit 9e5d32d

Browse files
committed
fix(knowledge): call checkAndBillOverageThreshold after embedding usage
1 parent d3c7bff commit 9e5d32d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

apps/sim/lib/knowledge/documents/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
sql,
2727
} from 'drizzle-orm'
2828
import { recordUsage } from '@/lib/billing/core/usage-log'
29+
import { checkAndBillOverageThreshold } from '@/lib/billing/threshold-billing'
2930
import { createBullMQJobData, isBullMQEnabled } from '@/lib/core/bullmq'
3031
import { env } from '@/lib/core/config/env'
3132
import { getCostMultiplier, isTriggerDevEnabled } from '@/lib/core/config/feature-flags'
@@ -682,6 +683,7 @@ export async function processDocumentAsync(
682683
totalTokensUsed: sql`total_tokens_used + ${totalEmbeddingTokens}`,
683684
},
684685
})
686+
await checkAndBillOverageThreshold(kb[0].userId)
685687
} else {
686688
logger.warn(
687689
`[${documentId}] Embedding model "${embeddingModelName}" has no pricing entry — billing skipped`,

0 commit comments

Comments
 (0)