@@ -234,10 +234,8 @@ func (p *PromptDebugApplicationImpl) doDebugStreaming(ctx context.Context, req *
234234 // execute
235235 resultStream := make (chan * entity.Reply )
236236 errChan := make (chan error )
237- replyChan := make (chan * entity.Reply , 1 )
238237 goroutine .GoSafe (ctx , func () {
239238 var executeErr error
240- var localReply * entity.Reply
241239 defer func () {
242240 e := recover ()
243241 if e != nil {
@@ -249,15 +247,13 @@ func (p *PromptDebugApplicationImpl) doDebugStreaming(ctx context.Context, req *
249247 errChan <- executeErr
250248 }
251249 close (errChan )
252- replyChan <- localReply
253- close (replyChan )
254250 }()
255251 defer func () {
256252 // 写入调试记录
257253 logErr := p .saveDebugLog (context .WithoutCancel (ctx ), saveDebugLogParam {
258254 prompt : prompt ,
259255 startTime : startTime ,
260- result : localReply ,
256+ result : aggregatedReply ,
261257 err : executeErr ,
262258 singleStepDebug : req .GetSingleStepDebug (),
263259 })
@@ -273,7 +269,7 @@ func (p *PromptDebugApplicationImpl) doDebugStreaming(ctx context.Context, req *
273269 if executeErr != nil {
274270 return
275271 }
276- localReply , executeErr = p .promptService .ExecuteStreaming (ctx , service.ExecuteStreamingParam {
272+ aggregatedReply , executeErr = p .promptService .ExecuteStreaming (ctx , service.ExecuteStreamingParam {
277273 ExecuteParam : service.ExecuteParam {
278274 Prompt : prompt ,
279275 Messages : messages ,
@@ -337,7 +333,6 @@ func (p *PromptDebugApplicationImpl) doDebugStreaming(ctx context.Context, req *
337333 logs .CtxError (ctx , "debug streaming failed, err=%v" , err )
338334 }
339335 }
340- aggregatedReply = <- replyChan
341336 return aggregatedReply , err
342337 }
343338}
0 commit comments