Skip to content

Commit 4747934

Browse files
authored
Bugfix/Prevent sending non image file (#3173)
* bugfix to prevent sending non image file * fix typo
1 parent 1e8839e commit 4747934

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/components/src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ export const mapChatMessageToBaseMessage = async (chatmessages: any[] = []): Pro
616616
const uploads = JSON.parse(message.fileUploads)
617617
const imageContents: MessageContentImageUrl[] = []
618618
for (const upload of uploads) {
619-
if (upload.type === 'stored-file') {
619+
if (upload.type === 'stored-file' && upload.mime.startsWith('image')) {
620620
const fileData = await getFileFromStorage(upload.name, message.chatflowid, message.chatId)
621621
// as the image is stored in the server, read the file and convert it to base64
622622
const bf = 'data:' + upload.mime + ';base64,' + fileData.toString('base64')
@@ -627,7 +627,7 @@ export const mapChatMessageToBaseMessage = async (chatmessages: any[] = []): Pro
627627
url: bf
628628
}
629629
})
630-
} else if (upload.type === 'url') {
630+
} else if (upload.type === 'url' && upload.mime.startsWith('image')) {
631631
imageContents.push({
632632
type: 'image_url',
633633
image_url: {

packages/ui/src/ui-component/dialog/ViewMessagesDialog.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
203203
}
204204
if (filePaths.length) msg.filePaths = filePaths
205205
if (chatmsg.sourceDocuments) msg.sourceDocuments = chatmsg.sourceDocuments
206-
if (chatmsg.usedTools) msg.usedTools = Jchatmsg.usedTools
206+
if (chatmsg.usedTools) msg.usedTools = chatmsg.usedTools
207207
if (chatmsg.fileAnnotations) msg.fileAnnotations = chatmsg.fileAnnotations
208208
if (chatmsg.feedback) msg.feedback = chatmsg.feedback?.content
209209
if (chatmsg.agentReasoning) msg.agentReasoning = chatmsg.agentReasoning

0 commit comments

Comments
 (0)