From 9dff0646ce3768232f39ce24eb679e258e147135 Mon Sep 17 00:00:00 2001 From: Yongtae Date: Fri, 25 Aug 2023 16:47:44 +0900 Subject: [PATCH] adopt optional credential on LLM --- .../llms/GoogleVertexAI/GoogleVertexAI.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts b/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts index 22133535..b379ad47 100644 --- a/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts +++ b/packages/components/nodes/llms/GoogleVertexAI/GoogleVertexAI.ts @@ -28,7 +28,10 @@ class GoogleVertexAI_LLMs implements INode { label: 'Connect Credential', name: 'credential', type: 'credential', - credentialNames: ['googleVertexAuth'] + credentialNames: ['googleVertexAuth'], + optional: true, + description: + 'Google Vertex AI credential. If you are using a GCP service like Cloud Run, or if you have installed default credentials on your local machine, you do not need to set this credential.' } this.inputs = [ { @@ -84,19 +87,15 @@ class GoogleVertexAI_LLMs implements INode { const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData) - - if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential) - throw new Error('Please specify your Google Application Credential') - 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 (!skipExtraCredentialFile) { + if (Object.keys(credentialData).length !== 0) { + if (!googleApplicationCredentialFilePath && !googleApplicationCredential) + throw new Error('Please specify your Google Application Credential') + if (!googleApplicationCredentialFilePath && !googleApplicationCredential) + throw new Error( + 'Error: More than one component has been inputted. Please use only one of the following: Google Application Credential File Path or Google Credential JSON Object' + ) + if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath else if (!googleApplicationCredentialFilePath && googleApplicationCredential) @@ -114,6 +113,7 @@ class GoogleVertexAI_LLMs implements INode { temperature: parseFloat(temperature), model: modelName } + if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10) if (topP) obj.topP = parseFloat(topP)