fix: use getChatProvider in organize-notebook to support Anthropic and add detailed error logs
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m26s

This commit is contained in:
Antigravity
2026-05-10 18:54:29 +00:00
parent 6123dcfba4
commit c8b1e2d3ed

View File

@@ -2,7 +2,7 @@
import { auth } from '@/auth'
import prisma from '@/lib/prisma'
import { getAIProvider } from '@/lib/ai/factory'
import { getChatProvider } from '@/lib/ai/factory'
import { getSystemConfig } from '@/lib/config'
import { revalidatePath } from 'next/cache'
@@ -119,10 +119,23 @@ Format de réponse JSON attendu:
]
}`
// 5. Call AI
// 5. Call AI using the chat provider (not embeddings provider)
const config = await getSystemConfig()
const provider = getAIProvider(config)
const rawResponse = await provider.generateText(prompt)
let provider
try {
provider = getChatProvider(config)
} catch (providerErr) {
console.error('[organize-notebook] Failed to get AI provider:', providerErr)
return { success: false, error: `Fournisseur IA non configuré : ${(providerErr as Error).message}` }
}
let rawResponse: string
try {
rawResponse = await provider.generateText(prompt)
} catch (aiErr) {
console.error('[organize-notebook] AI generateText failed:', aiErr)
return { success: false, error: `L'IA n'a pas pu répondre : ${(aiErr as Error).message}` }
}
// 6. Parse AI response
let parsed: { groups: Array<{ name: string; existingId?: string | null; noteIds: string[] }> }