MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / handleThinkingEvent

Function handleThinkingEvent

packages/ui/src/views/chatmessage/ChatMessage.jsx:646–670  ·  view source on GitHub ↗
(data, duration)

Source from the content-addressed store, hash-verified

644 }
645
646 const handleThinkingEvent = (data, duration) => {
647 if (data && duration === undefined) {
648 // Still thinking - append content
649 setIsThinking(true)
650 setMessages((prevMessages) => {
651 let allMessages = [...cloneDeep(prevMessages)]
652 if (allMessages[allMessages.length - 1].type === 'userMessage') return allMessages
653 const lastMessage = allMessages[allMessages.length - 1]
654 lastMessage.thinking = (lastMessage.thinking || '') + data
655 lastMessage.isThinking = true
656 return allMessages
657 })
658 } else if (data === '' && duration !== undefined) {
659 // Thinking finished - set duration
660 setIsThinking(false)
661 setMessages((prevMessages) => {
662 let allMessages = [...cloneDeep(prevMessages)]
663 if (allMessages[allMessages.length - 1].type === 'userMessage') return allMessages
664 const lastMessage = allMessages[allMessages.length - 1]
665 lastMessage.thinkingDuration = duration
666 lastMessage.isThinking = false
667 return allMessages
668 })
669 }
670 }
671
672 const finalizeThinking = () => {
673 // Clean up thinking state if stream ends unexpectedly

Callers 1

onmessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected