mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
implementation of chat model
This commit is contained in:
@@ -20,9 +20,9 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
this.name = 'chatGoogleVertexAI'
|
this.name = 'chatGoogleVertexAI'
|
||||||
this.version = 1.0
|
this.version = 1.0
|
||||||
this.type = 'ChatGoogleVertexAI'
|
this.type = 'ChatGoogleVertexAI'
|
||||||
this.icon = 'vertexai.svg'
|
this.icon = 'vertexa1i.svg'
|
||||||
this.category = 'Chat Models'
|
this.category = 'Chat Models'
|
||||||
this.description = 'Wrapper around VertexAI large language models that use the Chat endpoint'
|
this.description = 'wassyoi'
|
||||||
this.baseClasses = [this.type, ...getBaseClasses(ChatGoogleVertexAI)]
|
this.baseClasses = [this.type, ...getBaseClasses(ChatGoogleVertexAI)]
|
||||||
this.credential = {
|
this.credential = {
|
||||||
label: 'Connect Credential',
|
label: 'Connect Credential',
|
||||||
@@ -37,7 +37,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
type: 'options',
|
type: 'options',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: 'chat-bison',
|
label: 'chat-bison11111',
|
||||||
name: 'chat-bison'
|
name: 'chat-bison'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
name: 'codechat-bison'
|
name: 'codechat-bison'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: 'chat-bison',
|
default: 'chat-bison11111',
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -77,21 +77,31 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
|
|
||||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const skipExtraCredentialFile = getCredentialParam('skipExtraCredentialFile', credentialData, nodeData)
|
||||||
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
||||||
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
|
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
|
||||||
const projectID = getCredentialParam('projectID', credentialData, nodeData)
|
const projectID = getCredentialParam('projectID', credentialData, nodeData)
|
||||||
|
|
||||||
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
|
// if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
throw new Error('Please specify your Google Application Credential')
|
// throw new Error('Please specify your Google Application Credential')
|
||||||
if (googleApplicationCredentialFilePath && googleApplicationCredential)
|
|
||||||
throw new Error('Please use either Google Application Credential File Path or Google Credential JSON Object')
|
const inputs = [googleApplicationCredentialFilePath, googleApplicationCredential, skipExtraCredentialFile]
|
||||||
|
|
||||||
|
if (inputs.filter(Boolean).length > 1) {
|
||||||
|
throw new Error(
|
||||||
|
'Error: More than one component has been inputted. Please use only one of the following: Google Application Credential File Path, Google Credential JSON Object, or Skip Extra Credential File.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const authOptions: GoogleAuthOptions = {}
|
const authOptions: GoogleAuthOptions = {}
|
||||||
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
|
if (!skipExtraCredentialFile) {
|
||||||
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
if (googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
authOptions.keyFile = googleApplicationCredentialFilePath
|
||||||
|
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
||||||
|
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
||||||
|
|
||||||
if (projectID) authOptions.projectId = projectID
|
if (projectID) authOptions.projectId = projectID
|
||||||
|
}
|
||||||
|
|
||||||
const temperature = nodeData.inputs?.temperature as string
|
const temperature = nodeData.inputs?.temperature as string
|
||||||
const modelName = nodeData.inputs?.modelName as string
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
@@ -100,9 +110,9 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
|
|
||||||
const obj: Partial<GoogleVertexAIChatInput> = {
|
const obj: Partial<GoogleVertexAIChatInput> = {
|
||||||
temperature: parseFloat(temperature),
|
temperature: parseFloat(temperature),
|
||||||
model: modelName,
|
model: modelName
|
||||||
authOptions
|
|
||||||
}
|
}
|
||||||
|
if (authOptions) obj.authOptions = authOptions
|
||||||
|
|
||||||
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
||||||
if (topP) obj.topP = parseFloat(topP)
|
if (topP) obj.topP = parseFloat(topP)
|
||||||
|
|||||||
Reference in New Issue
Block a user