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

Function updateMetadata

packages/ui/src/views/chatmessage/ChatMessage.jsx:911–946  ·  view source on GitHub ↗
(data, input)

Source from the content-addressed store, hash-verified

909 }
910
911 const updateMetadata = (data, input) => {
912 // set message id that is needed for feedback
913 if (data.chatMessageId) {
914 setMessages((prevMessages) => {
915 let allMessages = [...cloneDeep(prevMessages)]
916 if (allMessages[allMessages.length - 1].type === 'apiMessage') {
917 allMessages[allMessages.length - 1].id = data.chatMessageId
918 }
919 return allMessages
920 })
921 }
922
923 if (data.chatId) {
924 setChatId(data.chatId)
925 }
926
927 if (input === '' && data.question) {
928 // the response contains the question even if it was in an audio format
929 // so if input is empty but the response contains the question, update the user message to show the question
930 setMessages((prevMessages) => {
931 let allMessages = [...cloneDeep(prevMessages)]
932 if (allMessages[allMessages.length - 2].type === 'apiMessage') return allMessages
933 allMessages[allMessages.length - 2].message = data.question
934 return allMessages
935 })
936 }
937
938 if (data.followUpPrompts) {
939 const followUpPrompts = JSON.parse(data.followUpPrompts)
940 if (typeof followUpPrompts === 'string') {
941 setFollowUpPrompts(JSON.parse(followUpPrompts))
942 } else {
943 setFollowUpPrompts(followUpPrompts)
944 }
945 }
946 }
947
948 const handleFileUploads = async (uploads) => {
949 if (!uploadedFiles.length) return uploads

Callers 2

handleSubmitFunction · 0.85
onmessageFunction · 0.85

Calls 1

parseMethod · 0.65

Tested by

no test coverage detected