Skip to content

Commit

Permalink
fix bug where uploaded file type is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryHengZJ committed Dec 4, 2024
1 parent ba8a462 commit 4c884ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/ui/src/views/chatmessage/ChatMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
const reader = new FileReader()
const { name } = file
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
if (!file.type || !imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push({ file, type: fullFileUpload ? 'file:full' : 'file:rag' })
}
files.push(
Expand Down Expand Up @@ -363,7 +363,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
return
}
// Only add files
if (!imageUploadAllowedTypes.includes(file.type)) {
if (!file.type || !imageUploadAllowedTypes.includes(file.type)) {
uploadedFiles.push({ file, type: fullFileUpload ? 'file:full' : 'file:rag' })
}
const reader = new FileReader()
Expand Down Expand Up @@ -700,6 +700,8 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
const handleFileUploads = async (uploads) => {
if (!uploadedFiles.length) return uploads

console.log('uploadedFiles', uploadedFiles)

Check failure on line 703 in packages/ui/src/views/chatmessage/ChatMessage.jsx

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Unexpected console statement

if (fullFileUpload) {
const filesWithFullUploadType = uploadedFiles.filter((file) => file.type === 'file:full')
if (filesWithFullUploadType.length > 0) {
Expand Down Expand Up @@ -794,6 +796,8 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
return
}

console.log('uploads', uploads)

Check failure on line 799 in packages/ui/src/views/chatmessage/ChatMessage.jsx

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Unexpected console statement

clearPreviews()
setMessages((prevMessages) => [...prevMessages, { message: input, type: 'userMessage', fileUploads: uploads }])

Expand Down

0 comments on commit 4c884ce

Please sign in to comment.