mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Structural Changes to support expansion to other chat models.
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
import { IMultiModalOption } from './Interface'
|
||||||
|
|
||||||
|
export interface IVisionChatModal {
|
||||||
|
id: string
|
||||||
|
configuredModel: string
|
||||||
|
configuredMaxToken: number
|
||||||
|
multiModalOption: IMultiModalOption
|
||||||
|
|
||||||
|
setVisionModel(): void
|
||||||
|
revertToOriginalModel(): void
|
||||||
|
setMultiModalOption(multiModalOption: IMultiModalOption): void
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ICommonObject, IFileUpload, IMultiModalOption, INodeData, MessageContentImageUrl } from './Interface'
|
import { ICommonObject, IFileUpload, IMultiModalOption, INodeData, MessageContentImageUrl } from './Interface'
|
||||||
import { ChatOpenAI } from '../nodes/chatmodels/ChatOpenAI/FlowiseChatOpenAI'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getStoragePath } from './utils'
|
import { getStoragePath } from './utils'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import { IVisionChatModal } from './IVisionChatModal'
|
||||||
|
|
||||||
export const addImagesToMessages = (
|
export const addImagesToMessages = (
|
||||||
nodeData: INodeData,
|
nodeData: INodeData,
|
||||||
@@ -12,7 +12,7 @@ export const addImagesToMessages = (
|
|||||||
const imageContent: MessageContentImageUrl[] = []
|
const imageContent: MessageContentImageUrl[] = []
|
||||||
let model = nodeData.inputs?.model
|
let model = nodeData.inputs?.model
|
||||||
|
|
||||||
if (model instanceof ChatOpenAI && multiModalOption) {
|
if (llmSupportsVision(model) && multiModalOption) {
|
||||||
// Image Uploaded
|
// Image Uploaded
|
||||||
if (multiModalOption.image && multiModalOption.image.allowImageUploads && options?.uploads && options?.uploads.length > 0) {
|
if (multiModalOption.image && multiModalOption.image.allowImageUploads && options?.uploads && options?.uploads.length > 0) {
|
||||||
const imageUploads = getImageUploads(options.uploads)
|
const imageUploads = getImageUploads(options.uploads)
|
||||||
@@ -46,3 +46,5 @@ export const getAudioUploads = (uploads: IFileUpload[]) => {
|
|||||||
export const getImageUploads = (uploads: IFileUpload[]) => {
|
export const getImageUploads = (uploads: IFileUpload[]) => {
|
||||||
return uploads.filter((upload: IFileUpload) => upload.mime.startsWith('image/'))
|
return uploads.filter((upload: IFileUpload) => upload.mime.startsWith('image/'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const llmSupportsVision = (value: any): value is IVisionChatModal => !!value?.multiModalOption
|
||||||
|
|||||||
Reference in New Issue
Block a user