fix(agent): 修复WeKnora对话完前端未显示结束标记问题

fix(agent): 修复流式回答think内容与answer混淆问题
This commit is contained in:
bingxiang.cheng
2026-05-03 23:09:58 +08:00
committed by lyingbug
parent 7adf88766a
commit a232b12ff0
5 changed files with 80 additions and 13 deletions
+11 -6
View File
@@ -15,11 +15,12 @@ import (
// streamLLMResult holds accumulated output from a streaming LLM call.
type streamLLMResult struct {
Content string
ToolCalls []types.LLMToolCall
Usage *types.TokenUsage
FinishReason string // actual finish_reason from LLM (captured from last stream chunk)
StreamError string // error message from stream (e.g., timeout), kept separate from Content
Content string
ThinkingContent string // accumulated thinking/reasoning content, kept separate from answer
ToolCalls []types.LLMToolCall
Usage *types.TokenUsage
FinishReason string // actual finish_reason from LLM (captured from last stream chunk)
StreamError string // error message from stream (e.g., timeout), kept separate from Content
}
// streamLLMToEventBus streams LLM response through EventBus (generic method)
@@ -64,7 +65,11 @@ func (e *AgentEngine) streamLLMToEventBus(
if chunk.Content != "" {
isExtracted := chunk.Data != nil && chunk.Data["source"] != nil
if !isExtracted {
result.Content += chunk.Content
if chunk.ResponseType == types.ResponseTypeThinking {
result.ThinkingContent += chunk.Content
} else {
result.Content += chunk.Content
}
}
}