fix panic : appels OnChunk sans garde de nil dans AnyLLMEngine.Stream (crash du serveur lors d'un appel d'outil hors streaming, ex. tâche planifiée)

This commit is contained in:
fabien committed 2026-10-06 23:46:17 +02:00
1 parent 535603f6d3
commit 5863858b09
1 file changed
+16 -12
+16 -12
View File
@@ -168,13 +168,15 @@ func (e *AnyLLMEngine) Stream(
Extra: extra, Extra: extra,
}) })
params.OnChunk(&domain.Chunk{ if params.OnChunk != nil {
Done: false, params.OnChunk(&domain.Chunk{
ToolName: tc.Function.Name, Done: false,
Role: anyllm.RoleAssistant, ToolName: tc.Function.Name,
Content: tc.Function.Arguments, Role: anyllm.RoleAssistant,
Reasoning: false, Content: tc.Function.Arguments,
}) Reasoning: false,
})
}
} }
@@ -182,11 +184,13 @@ func (e *AnyLLMEngine) Stream(
} }
if !toolCalling { if !toolCalling {
params.OnChunk(&domain.Chunk{ if params.OnChunk != nil {
Done: true, params.OnChunk(&domain.Chunk{
Role: anyllm.RoleAssistant, Done: true,
Content: "", Role: anyllm.RoleAssistant,
}) Content: "",
})
}
} }
if err := <-errChan; err != nil { if err := <-errChan; err != nil {