fix: Improve result handling in Assistant API streamChat method

- Refactored the result handling logic to ensure that the output is sent to the client correctly, whether a callback is provided or not.
- Simplified the flow by removing redundant callback handling when a result is available.
This commit is contained in:
Max 2025-05-09 12:09:19 +08:00
parent 4c7b1547e8
commit dc54d17f2b

View file

@ -591,11 +591,17 @@ func (ast *Assistant) streamChat(
}
// has result
if res != nil && res.Result != nil && cb != nil {
if res != nil && res.Result != nil {
output.SetResult(res.Result)
if cb != nil {
output.Callback(cb).Write(c.Writer)
return 0 // break
}
// Send the result to the client
output.Write(c.Writer)
return 0 // break
}
output.Callback(cb).Write(c.Writer)
return 0 // break
}