mirror of
https://github.com/langgenius/dify.git
synced 2026-07-28 23:59:34 +08:00
fix: final answer in new agent would clear after sse if agent thought has answer (#38649)
This commit is contained in:
parent
d0f0134314
commit
4a8c6773a3
@ -2010,7 +2010,7 @@ describe('useChat', () => {
|
||||
})
|
||||
|
||||
const lastResponse = result.current.chatList[1]
|
||||
expect(lastResponse!.content).toBe('')
|
||||
expect(lastResponse!.content).toBe('history top-level answer')
|
||||
expect(lastResponse!.agent_response_parts).toBeUndefined()
|
||||
expect(lastResponse!.workflow_run_id).toBe('history-workflow-run')
|
||||
expect(lastResponse!.workflowProcess).toBeUndefined()
|
||||
|
||||
@ -984,10 +984,9 @@ export const useChat = (
|
||||
return onConversationComplete?.(conversationIdRef.current, completedWorkflowRunId)
|
||||
|
||||
const historyAgentThoughts = getHistoryAgentThoughts(newResponseItem)
|
||||
const hasHistoryAgentThoughtAnswer = historyAgentThoughts.some(thought => thought.answer?.trim())
|
||||
const lastHistoryAgentThought = historyAgentThoughts.at(-1)
|
||||
const historyAnswer = newResponseItem.answer || ''
|
||||
const isUseAgentThought = (lastHistoryAgentThought?.thought === historyAnswer) || (options.isNewAgent && hasHistoryAgentThoughtAnswer)
|
||||
const isUseAgentThought = !options.isNewAgent && lastHistoryAgentThought?.thought === historyAnswer
|
||||
const messageLog = Array.isArray(newResponseItem.message) ? newResponseItem.message : []
|
||||
const answerTokens = newResponseItem.answer_tokens ?? 0
|
||||
const messageTokens = newResponseItem.message_tokens ?? 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user