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:
1 parent
535603f6d3
commit
5863858b09
1 file changed
+16
-12
@@ -168,13 +168,15 @@ func (e *AnyLLMEngine) Stream(
|
||||
Extra: extra,
|
||||
})
|
||||
|
||||
params.OnChunk(&domain.Chunk{
|
||||
Done: false,
|
||||
ToolName: tc.Function.Name,
|
||||
Role: anyllm.RoleAssistant,
|
||||
Content: tc.Function.Arguments,
|
||||
Reasoning: false,
|
||||
})
|
||||
if params.OnChunk != nil {
|
||||
params.OnChunk(&domain.Chunk{
|
||||
Done: false,
|
||||
ToolName: tc.Function.Name,
|
||||
Role: anyllm.RoleAssistant,
|
||||
Content: tc.Function.Arguments,
|
||||
Reasoning: false,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -182,11 +184,13 @@ func (e *AnyLLMEngine) Stream(
|
||||
}
|
||||
|
||||
if !toolCalling {
|
||||
params.OnChunk(&domain.Chunk{
|
||||
Done: true,
|
||||
Role: anyllm.RoleAssistant,
|
||||
Content: "",
|
||||
})
|
||||
if params.OnChunk != nil {
|
||||
params.OnChunk(&domain.Chunk{
|
||||
Done: true,
|
||||
Role: anyllm.RoleAssistant,
|
||||
Content: "",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err := <-errChan; err != nil {
|
||||
|
||||
Reference in new issue
Block a user