diff --git a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts index 23bd3565..99ee78b5 100644 --- a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts +++ b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts @@ -38,23 +38,33 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData) + const skipExtraCredentialFile = getCredentialParam('skipExtraCredentialFile', 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 (!skipExtraCredentialFile){ + if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath + else if (!googleApplicationCredentialFilePath && googleApplicationCredential) + authOptions.credentials = JSON.parse(googleApplicationCredential) - if (projectID) authOptions.projectId = projectID - - const obj: GoogleVertexAIEmbeddingsParams = { - authOptions + if (projectID) authOptions.projectId = projectID } + const obj: GoogleVertexAIEmbeddingsParams = {} + if (authOptions) obj.authOptions = authOptions + const model = new GoogleVertexAIEmbeddings(obj) return model }