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
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 5s
Made-with: Cursor
This commit is contained in:
@@ -84,7 +84,12 @@ export function NotebooksProvider({ children, initialNotebooks = [] }: Notebooks
|
|||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const [isMovingNote, setIsMovingNote] = useState(false)
|
const [isMovingNote, setIsMovingNote] = useState(false)
|
||||||
const [error, setError] = useState<string | null>(null)
|
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 =====
|
// ===== DERIVED STATE =====
|
||||||
const currentLabels = useMemo(() => {
|
const currentLabels = useMemo(() => {
|
||||||
|
|||||||
@@ -901,6 +901,24 @@ async function executeToolUseAgent(
|
|||||||
|
|
||||||
const duration = Date.now() - startTime
|
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
|
// Build tool log trace
|
||||||
const toolLog = result.steps.map((step, i) => ({
|
const toolLog = result.steps.map((step, i) => ({
|
||||||
step: i + 1,
|
step: i + 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user