This commit is contained in:
Yongtae
2023-08-24 11:42:49 +09:00
parent 0830b8fbe5
commit d9113da6bb
3 changed files with 17 additions and 21 deletions
@@ -49,7 +49,6 @@ class GoogleVertexAuth implements INodeCredential {
optional: true optional: true
}, },
{ {
label: 'Project ID', label: 'Project ID',
name: 'projectID', name: 'projectID',
@@ -43,19 +43,18 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential) if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential)
throw new Error('Please specify your Google Application Credential') throw new Error('Please specify your Google Application Credential')
const inputs = [ const inputs = [googleApplicationCredentialFilePath, googleApplicationCredential, skipExtraCredentialFile]
googleApplicationCredentialFilePath,
googleApplicationCredential,
skipExtraCredentialFile
];
if (inputs.filter(Boolean).length > 1) { 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.') 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 (!skipExtraCredentialFile){ if (!skipExtraCredentialFile) {
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath if (googleApplicationCredentialFilePath && !googleApplicationCredential)
authOptions.keyFile = googleApplicationCredentialFilePath
else if (!googleApplicationCredentialFilePath && googleApplicationCredential) else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
authOptions.credentials = JSON.parse(googleApplicationCredential) authOptions.credentials = JSON.parse(googleApplicationCredential)
@@ -85,22 +85,20 @@ class GoogleVertexAI_LLMs implements INode {
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 (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential) if (!skipExtraCredentialFile && !googleApplicationCredentialFilePath && !googleApplicationCredential)
throw new Error('Please specify your Google Application Credential') throw new Error('Please specify your Google Application Credential')
const inputs = [ const inputs = [googleApplicationCredentialFilePath, googleApplicationCredential, skipExtraCredentialFile]
googleApplicationCredentialFilePath,
googleApplicationCredential,
skipExtraCredentialFile
];
if (inputs.filter(Boolean).length > 1) { 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.') 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 (!skipExtraCredentialFile){ if (!skipExtraCredentialFile) {
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath if (googleApplicationCredentialFilePath && !googleApplicationCredential)
authOptions.keyFile = googleApplicationCredentialFilePath
else if (!googleApplicationCredentialFilePath && googleApplicationCredential) else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
authOptions.credentials = JSON.parse(googleApplicationCredential) authOptions.credentials = JSON.parse(googleApplicationCredential)
@@ -114,7 +112,7 @@ class GoogleVertexAI_LLMs implements INode {
const obj: Partial<GoogleVertexAITextInput> = { const obj: Partial<GoogleVertexAITextInput> = {
temperature: parseFloat(temperature), temperature: parseFloat(temperature),
model: modelName, model: modelName
} }
if (authOptions) obj.authOptions = authOptions if (authOptions) obj.authOptions = authOptions