mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 05:01:10 +03:00
start of changes to AzureOpenAI to support Image uploads
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { AzureOpenAIInput, ChatOpenAI as LangchainChatOpenAI, OpenAIChatInput } from '@langchain/openai'
|
import { AzureOpenAIInput, ChatOpenAI as LangchainChatOpenAI, OpenAIChatInput } from '@langchain/openai'
|
||||||
import { BaseCache } from '@langchain/core/caches'
|
import { BaseCache } from '@langchain/core/caches'
|
||||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||||
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeParams } from "../../../src/Interface";
|
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { ChatOpenAI } from '../ChatOpenAI/FlowiseChatOpenAI'
|
import { ChatOpenAI } from '../ChatOpenAI/FlowiseChatOpenAI'
|
||||||
|
|
||||||
@@ -103,38 +103,38 @@ class AzureChatOpenAI_ChatModels implements INode {
|
|||||||
step: 1,
|
step: 1,
|
||||||
optional: true,
|
optional: true,
|
||||||
additionalParams: true
|
additionalParams: true
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: 'Allow Image Uploads',
|
// label: 'Allow Image Uploads',
|
||||||
name: 'allowImageUploads',
|
// name: 'allowImageUploads',
|
||||||
type: 'boolean',
|
// type: 'boolean',
|
||||||
description:
|
// description:
|
||||||
'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, and Conversational Agent',
|
// 'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, and Conversational Agent',
|
||||||
default: false,
|
// default: false,
|
||||||
optional: true
|
// optional: true
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: 'Image Resolution',
|
// label: 'Image Resolution',
|
||||||
description: 'This parameter controls the resolution in which the model views the image.',
|
// description: 'This parameter controls the resolution in which the model views the image.',
|
||||||
name: 'imageResolution',
|
// name: 'imageResolution',
|
||||||
type: 'options',
|
// type: 'options',
|
||||||
options: [
|
// options: [
|
||||||
{
|
// {
|
||||||
label: 'Low',
|
// label: 'Low',
|
||||||
name: 'low'
|
// name: 'low'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: 'High',
|
// label: 'High',
|
||||||
name: 'high'
|
// name: 'high'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: 'Auto',
|
// label: 'Auto',
|
||||||
name: 'auto'
|
// name: 'auto'
|
||||||
}
|
// }
|
||||||
],
|
// ],
|
||||||
default: 'low',
|
// default: 'low',
|
||||||
optional: false,
|
// optional: false,
|
||||||
additionalParams: true
|
// additionalParams: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -155,10 +155,10 @@ class AzureChatOpenAI_ChatModels implements INode {
|
|||||||
const azureOpenAIApiDeploymentName = getCredentialParam('azureOpenAIApiDeploymentName', credentialData, nodeData)
|
const azureOpenAIApiDeploymentName = getCredentialParam('azureOpenAIApiDeploymentName', credentialData, nodeData)
|
||||||
const azureOpenAIApiVersion = getCredentialParam('azureOpenAIApiVersion', credentialData, nodeData)
|
const azureOpenAIApiVersion = getCredentialParam('azureOpenAIApiVersion', credentialData, nodeData)
|
||||||
|
|
||||||
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
|
// const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
|
||||||
const imageResolution = nodeData.inputs?.imageResolution as string
|
// const imageResolution = nodeData.inputs?.imageResolution as string
|
||||||
|
|
||||||
const obj: Partial<AzureOpenAIInput> & BaseLLMParams & Partial<OpenAIChatInput> & { multiModalOption?: IMultiModalOption } = {
|
const obj: Partial<AzureOpenAIInput> & BaseLLMParams & Partial<OpenAIChatInput> = {
|
||||||
temperature: parseFloat(temperature),
|
temperature: parseFloat(temperature),
|
||||||
modelName,
|
modelName,
|
||||||
azureOpenAIApiKey,
|
azureOpenAIApiKey,
|
||||||
@@ -176,13 +176,12 @@ class AzureChatOpenAI_ChatModels implements INode {
|
|||||||
|
|
||||||
const multiModalOption: IMultiModalOption = {
|
const multiModalOption: IMultiModalOption = {
|
||||||
image: {
|
image: {
|
||||||
allowImageUploads: allowImageUploads ?? false,
|
allowImageUploads: false,
|
||||||
imageResolution
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.multiModalOption = multiModalOption
|
|
||||||
|
|
||||||
const model = new ChatOpenAI(nodeData.id, obj)
|
const model = new ChatOpenAI(nodeData.id, obj)
|
||||||
|
model.setMultiModalOption(multiModalOption)
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user