Feature/Add ability to upload image url when calling API (#2683)

add ability to upload image url when calling API
This commit is contained in:
Henry Heng 2024-06-19 23:26:56 +01:00 committed by GitHub
parent 72e5287343
commit 842bfc66fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -20,6 +20,14 @@ export const addImagesToMessages = async (
// as the image is stored in the server, read the file and convert it to base64
bf = 'data:' + upload.mime + ';base64,' + contents.toString('base64')
imageContent.push({
type: 'image_url',
image_url: {
url: bf,
detail: multiModalOption.image.imageResolution ?? 'low'
}
})
} else if (upload.type == 'url' && bf) {
imageContent.push({
type: 'image_url',
image_url: {

View File

@ -94,6 +94,12 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
fileUploads[i] = omit(upload, ['data'])
}
if (upload.type === 'url' && upload.data) {
const filename = upload.name
const urlData = upload.data
fileUploads[i] = { data: urlData, name: filename, type: 'url', mime: upload.mime ?? 'image/png' }
}
// Run Speech to Text conversion
if (upload.mime === 'audio/webm' || upload.mime === 'audio/mp4' || upload.mime === 'audio/ogg') {
logger.debug(`Attempting a speech to text conversion...`)