From dc54d17f2b641b83d2dc136ff4589443a47faa93 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 9 May 2025 12:09:19 +0800 Subject: [PATCH] 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. --- neo/assistant/api.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neo/assistant/api.go b/neo/assistant/api.go index 60e01702..0d38155f 100644 --- a/neo/assistant/api.go +++ b/neo/assistant/api.go @@ -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 }