Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/Prevent sending non image file #3173

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/components/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export const mapChatMessageToBaseMessage = async (chatmessages: any[] = []): Pro
const uploads = JSON.parse(message.fileUploads)
const imageContents: MessageContentImageUrl[] = []
for (const upload of uploads) {
if (upload.type === 'stored-file') {
if (upload.type === 'stored-file' && upload.mime.startsWith('image')) {
const fileData = await getFileFromStorage(upload.name, message.chatflowid, message.chatId)
// as the image is stored in the server, read the file and convert it to base64
const bf = 'data:' + upload.mime + ';base64,' + fileData.toString('base64')
Expand All @@ -627,7 +627,7 @@ export const mapChatMessageToBaseMessage = async (chatmessages: any[] = []): Pro
url: bf
}
})
} else if (upload.type === 'url') {
} else if (upload.type === 'url' && upload.mime.startsWith('image')) {
imageContents.push({
type: 'image_url',
image_url: {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/ui-component/dialog/ViewMessagesDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const ViewMessagesDialog = ({ show, dialogProps, onCancel }) => {
}
if (filePaths.length) msg.filePaths = filePaths
if (chatmsg.sourceDocuments) msg.sourceDocuments = chatmsg.sourceDocuments
if (chatmsg.usedTools) msg.usedTools = Jchatmsg.usedTools
if (chatmsg.usedTools) msg.usedTools = chatmsg.usedTools
if (chatmsg.fileAnnotations) msg.fileAnnotations = chatmsg.fileAnnotations
if (chatmsg.feedback) msg.feedback = chatmsg.feedback?.content
if (chatmsg.agentReasoning) msg.agentReasoning = chatmsg.agentReasoning
Expand Down
Loading