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:
@@ -16,6 +16,7 @@ import {
|
||||
buildMemoryEchoInsightPrompt,
|
||||
getMemoryEchoInsightFallback,
|
||||
} from '@/lib/ai/memory-echo-i18n'
|
||||
import { withAiQuota } from '@/lib/ai-quota'
|
||||
import {
|
||||
SEMANTIC_SIMILARITY_FLOOR_CLIP,
|
||||
SEMANTIC_SIMILARITY_FLOOR_DEMO,
|
||||
@@ -463,14 +464,20 @@ export class MemoryEchoService {
|
||||
return null // All connections already shown
|
||||
}
|
||||
|
||||
// Generate AI insight in user's language
|
||||
// Generate AI insight in user's language (quota: reformulate, with rollback on failure)
|
||||
const userLanguage = await detectUserLanguage()
|
||||
const insightText = await this.generateInsight(
|
||||
newConnection.note1.title,
|
||||
newConnection.note1.content,
|
||||
newConnection.note2.title,
|
||||
newConnection.note2.content || '',
|
||||
userLanguage,
|
||||
const insightText = await withAiQuota(
|
||||
userId,
|
||||
'reformulate',
|
||||
() =>
|
||||
this.generateInsight(
|
||||
newConnection.note1.title,
|
||||
newConnection.note1.content,
|
||||
newConnection.note2.title,
|
||||
newConnection.note2.content || '',
|
||||
userLanguage,
|
||||
),
|
||||
{ lane: 'chat' },
|
||||
)
|
||||
|
||||
// Store insight in database
|
||||
|
||||
Reference in New Issue
Block a user