diff --git a/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts b/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts index 4d9b3aeda..ef04883b5 100644 --- a/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts +++ b/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts @@ -80,20 +80,32 @@ class GoogleVertexAI_LLMs implements INode { async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const skipExtraCredentialFile = getCredentialParam('skipExtraCredentialFile', credentialData, nodeData) const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData) - if (!googleApplicationCredentialFilePath && !googleApplicationCredential) + + if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential) 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 = {} - if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath - else if (!googleApplicationCredentialFilePath && googleApplicationCredential) - authOptions.credentials = JSON.parse(googleApplicationCredential) - if (projectID) authOptions.projectId = projectID + if (!skipExtraCredentialFile){ + if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath + else if (!googleApplicationCredentialFilePath && googleApplicationCredential) + authOptions.credentials = JSON.parse(googleApplicationCredential) + + if (projectID) authOptions.projectId = projectID + } const temperature = nodeData.inputs?.temperature as string const modelName = nodeData.inputs?.modelName as string @@ -103,9 +115,10 @@ class GoogleVertexAI_LLMs implements INode { const obj: Partial = { temperature: parseFloat(temperature), model: modelName, - authOptions } + if (authOptions) obj.authOptions = authOptions + if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10) if (topP) obj.topP = parseFloat(topP)