adopt optional credential on LLM

This commit is contained in:
Yongtae
2023-08-25 16:47:44 +09:00
parent 495919a1d8
commit 9dff0646ce
@@ -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)