From feba9e11581604233e0e36135998e1fd88652568 Mon Sep 17 00:00:00 2001 From: euvre <93761161+euvre@users.noreply.github.com> Date: Thu, 16 Jul 2026 17:02:40 +0800 Subject: [PATCH] fix: custom empty_response not shown in streaming chat (Go mode) (#16989) --- internal/service/chat_pipeline.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/service/chat_pipeline.go b/internal/service/chat_pipeline.go index a9a524deee..d5978bf945 100644 --- a/internal/service/chat_pipeline.go +++ b/internal/service/chat_pipeline.go @@ -844,10 +844,19 @@ func (s *ChatPipelineService) AsyncChat( // return the user-configured fallback message (if set). // If empty_response is not configured, fall through to the LLM call // with an empty knowledge context. + // + // Two results are yielded (mirroring Python dialog_service.py): + // 1. Final=false — carries the answer text so streaming consumers + // actually display the fallback message. + // 2. Final=true — closes the stream with the reference/prompt. if len(knowledges) == 0 { if emptyResp, ok := promptConfig["empty_response"].(string); ok && emptyResp != "" { out <- AsyncChatResult{ - Answer: emptyResp, + Answer: emptyResp, + Reference: map[string]interface{}{}, + } + out <- AsyncChatResult{ + Answer: "", Reference: kbinfos, AudioBinary: s.synthesizeTTS(ttsModel, emptyResp), Prompt: fmt.Sprintf("\n\n### Query:\n%s", strings.Join(questions, " ")),