fix(quotas): unifier le décompte IA (BYOK, rollback) et combler les fuites
Centralise la réserve via ai-quota, corrige admin unavailable (-1), brancher les routes sans quota et le host-pays brainstorm, avec usage-meter élargi, noms de clusters, MCP et ajustements dashboard/insights. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import prisma from '@/lib/prisma'
|
||||
import { getChatProvider } from '@/lib/ai/factory'
|
||||
import { getSystemConfig } from '@/lib/config'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { withAiQuota } from '@/lib/ai-quota'
|
||||
import { QuotaExceededError } from '@/lib/entitlements'
|
||||
|
||||
export interface OrganizationNote {
|
||||
id: string
|
||||
@@ -134,8 +136,16 @@ Format de réponse JSON attendu:
|
||||
|
||||
let rawResponse: string
|
||||
try {
|
||||
rawResponse = await provider.generateText(prompt)
|
||||
rawResponse = await withAiQuota(
|
||||
session.user.id,
|
||||
'reformulate',
|
||||
() => provider.generateText(prompt),
|
||||
{ lane: 'chat' },
|
||||
)
|
||||
} catch (aiErr) {
|
||||
if (aiErr instanceof QuotaExceededError) {
|
||||
return { success: false, error: 'Quota IA épuisé pour cette fonctionnalité.' }
|
||||
}
|
||||
console.error('[organize-notebook] AI generateText failed:', aiErr)
|
||||
return { success: false, error: `L'IA n'a pas pu répondre : ${(aiErr as Error).message}` }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user