fix: notebook count updates on note delete, detect model without tool calling support
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 5s

Made-with: Cursor
This commit is contained in:
2026-04-25 23:12:58 +02:00
parent 70a9e070fc
commit 3fe69b65a5
2 changed files with 24 additions and 1 deletions

View File

@@ -84,7 +84,12 @@ export function NotebooksProvider({ children, initialNotebooks = [] }: Notebooks
const [isLoading, setIsLoading] = useState(true)
const [isMovingNote, setIsMovingNote] = useState(false)
const [error, setError] = useState<string | null>(null)
const { triggerRefresh } = useNoteRefresh() // Get triggerRefresh from context
const { triggerRefresh, refreshKey } = useNoteRefresh()
// Recharge les carnets à chaque fois qu'une note est modifiée/supprimée
useEffect(() => {
if (refreshKey > 0) loadNotebooks()
}, [refreshKey, loadNotebooks])
// ===== DERIVED STATE =====
const currentLabels = useMemo(() => {

View File

@@ -901,6 +901,24 @@ async function executeToolUseAgent(
const duration = Date.now() - startTime
// Détecte si le modèle ne supporte pas le function calling
// (il retourne le JSON de l'outil comme texte brut au lieu de l'exécuter)
const totalToolCallsCheck = result.steps.reduce((acc, s) => acc + s.toolCalls.length, 0)
if (totalToolCallsCheck === 0 && result.text) {
const trimmed = result.text.trim()
if (trimmed.startsWith('[{"type":"function"') || trimmed.startsWith('[{\n "type": "function"')) {
await prisma.agentAction.update({
where: { id: actionId },
data: {
status: 'error',
error: `Le modèle "${sysConfig.AI_MODEL_CHAT}" ne supporte pas le function calling (tool use). Utilisez un modèle compatible dans les paramètres admin, par exemple : openai/gpt-4o-mini, google/gemini-flash-1.5, anthropic/claude-3-haiku, ou mistralai/mistral-small.`,
completedAt: new Date(),
}
})
return { success: false, actionId, error: 'Model does not support tool calling' }
}
}
// Build tool log trace
const toolLog = result.steps.map((step, i) => ({
step: i + 1,