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
+4
@@ -168,6 +168,7 @@ func (e *AnyLLMEngine) Stream(
|
|||||||
Extra: extra,
|
Extra: extra,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if params.OnChunk != nil {
|
||||||
params.OnChunk(&domain.Chunk{
|
params.OnChunk(&domain.Chunk{
|
||||||
Done: false,
|
Done: false,
|
||||||
ToolName: tc.Function.Name,
|
ToolName: tc.Function.Name,
|
||||||
@@ -175,6 +176,7 @@ func (e *AnyLLMEngine) Stream(
|
|||||||
Content: tc.Function.Arguments,
|
Content: tc.Function.Arguments,
|
||||||
Reasoning: false,
|
Reasoning: false,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,12 +184,14 @@ func (e *AnyLLMEngine) Stream(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !toolCalling {
|
if !toolCalling {
|
||||||
|
if params.OnChunk != nil {
|
||||||
params.OnChunk(&domain.Chunk{
|
params.OnChunk(&domain.Chunk{
|
||||||
Done: true,
|
Done: true,
|
||||||
Role: anyllm.RoleAssistant,
|
Role: anyllm.RoleAssistant,
|
||||||
Content: "",
|
Content: "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := <-errChan; err != nil {
|
if err := <-errChan; err != nil {
|
||||||
return &domain.Message{
|
return &domain.Message{
|
||||||
|
|||||||
Reference in new issue
Block a user