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

Function handleSubmit

packages/ui/src/views/chatmessage/ChatMessage.jsx:1010–1118  ·  view source on GitHub ↗
(e, selectedInput, action, humanInput)

Source from the content-addressed store, hash-verified

1008
1009 // Handle form submission
1010 const handleSubmit = async (e, selectedInput, action, humanInput) => {
1011 if (e) e.preventDefault()
1012
1013 if (!selectedInput && userInput.trim() === '') {
1014 const containsFile = previews.filter((item) => !item.mime.startsWith('image') && item.type !== 'audio').length > 0
1015 if (!previews.length || (previews.length && containsFile)) {
1016 return
1017 }
1018 }
1019
1020 let input = userInput
1021
1022 if (typeof selectedInput === 'string') {
1023 if (selectedInput !== undefined && selectedInput.trim() !== '') input = selectedInput
1024
1025 if (input.trim()) {
1026 inputHistory.addToHistory(input)
1027 }
1028 } else if (typeof selectedInput === 'object') {
1029 input = Object.entries(selectedInput)
1030 .map(([key, value]) => `${key}: ${value}`)
1031 .join('\n')
1032 }
1033
1034 setLoading(true)
1035 clearAgentflowNodeStatus()
1036
1037 let uploads = previews.map((item) => {
1038 return {
1039 data: item.data,
1040 type: item.type,
1041 name: item.name,
1042 mime: item.mime
1043 }
1044 })
1045
1046 try {
1047 uploads = await handleFileUploads(uploads)
1048 } catch (error) {
1049 handleError('Unable to upload documents')
1050 return
1051 }
1052
1053 clearPreviews()
1054 setMessages((prevMessages) => [...prevMessages, { message: input, type: 'userMessage', fileUploads: uploads }])
1055
1056 // Send user question to Prediction Internal API
1057 try {
1058 const params = {
1059 question: input,
1060 chatId
1061 }
1062 if (typeof selectedInput === 'object') {
1063 params.form = selectedInput
1064 delete params.question
1065 }
1066 if (uploads && uploads.length > 0) params.uploads = uploads
1067 if (leadEmail) params.leadEmail = leadEmail

Callers 6

handlePromptClickFunction · 0.70
onSubmitResponseFunction · 0.70
handleActionClickFunction · 0.70
handleEnterFunction · 0.70
ChatMessageFunction · 0.70

Calls 10

setLocalStorageChatflowFunction · 0.90
clearAgentflowNodeStatusFunction · 0.85
handleFileUploadsFunction · 0.85
clearPreviewsFunction · 0.85
updateMetadataFunction · 0.85
scrollToBottomFunction · 0.85
addToHistoryMethod · 0.80
stringifyMethod · 0.80
handleErrorFunction · 0.70

Tested by

no test coverage detected