mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Merge pull request #824 from Yongtae723/fix/google_credential
add skip extra credential on google credential
This commit is contained in:
@@ -28,7 +28,10 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
label: 'Connect Credential',
|
label: 'Connect Credential',
|
||||||
name: 'credential',
|
name: 'credential',
|
||||||
type: '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 = [
|
this.inputs = [
|
||||||
{
|
{
|
||||||
@@ -81,17 +84,22 @@ class GoogleVertexAI_ChatModels 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 (!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 authOptions: GoogleAuthOptions = {}
|
const authOptions: GoogleAuthOptions = {}
|
||||||
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
|
if (Object.keys(credentialData).length !== 0) {
|
||||||
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
authOptions.credentials = JSON.parse(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 (projectID) authOptions.projectId = projectID
|
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 temperature = nodeData.inputs?.temperature as string
|
||||||
const modelName = nodeData.inputs?.modelName as string
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
@@ -100,9 +108,9 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||||||
|
|
||||||
const obj: Partial<GoogleVertexAIChatInput> = {
|
const obj: Partial<GoogleVertexAIChatInput> = {
|
||||||
temperature: parseFloat(temperature),
|
temperature: parseFloat(temperature),
|
||||||
model: modelName,
|
model: modelName
|
||||||
authOptions
|
|
||||||
}
|
}
|
||||||
|
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
|
||||||
|
|
||||||
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
||||||
if (topP) obj.topP = parseFloat(topP)
|
if (topP) obj.topP = parseFloat(topP)
|
||||||
|
|||||||
+18
-12
@@ -28,7 +28,10 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
|||||||
label: 'Connect Credential',
|
label: 'Connect Credential',
|
||||||
name: 'credential',
|
name: 'credential',
|
||||||
type: '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 = []
|
this.inputs = []
|
||||||
}
|
}
|
||||||
@@ -39,21 +42,24 @@ class GoogleVertexAIEmbedding_Embeddings 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 (!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 authOptions: GoogleAuthOptions = {}
|
const authOptions: GoogleAuthOptions = {}
|
||||||
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
|
if (Object.keys(credentialData).length !== 0) {
|
||||||
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
authOptions.credentials = JSON.parse(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 (projectID) authOptions.projectId = projectID
|
if (googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
|
authOptions.keyFile = googleApplicationCredentialFilePath
|
||||||
|
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
||||||
|
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
||||||
|
|
||||||
const obj: GoogleVertexAIEmbeddingsParams = {
|
if (projectID) authOptions.projectId = projectID
|
||||||
authOptions
|
|
||||||
}
|
}
|
||||||
|
const obj: GoogleVertexAIEmbeddingsParams = {}
|
||||||
|
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
|
||||||
|
|
||||||
const model = new GoogleVertexAIEmbeddings(obj)
|
const model = new GoogleVertexAIEmbeddings(obj)
|
||||||
return model
|
return model
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ class GoogleVertexAI_LLMs implements INode {
|
|||||||
label: 'Connect Credential',
|
label: 'Connect Credential',
|
||||||
name: 'credential',
|
name: 'credential',
|
||||||
type: '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 = [
|
this.inputs = [
|
||||||
{
|
{
|
||||||
@@ -84,16 +87,22 @@ 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 (!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 authOptions: GoogleAuthOptions = {}
|
const authOptions: GoogleAuthOptions = {}
|
||||||
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
|
if (Object.keys(credentialData).length !== 0) {
|
||||||
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||||
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
throw new Error('Please specify your Google Application Credential')
|
||||||
if (projectID) authOptions.projectId = projectID
|
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)
|
||||||
|
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
||||||
|
|
||||||
|
if (projectID) authOptions.projectId = projectID
|
||||||
|
}
|
||||||
|
|
||||||
const temperature = nodeData.inputs?.temperature as string
|
const temperature = nodeData.inputs?.temperature as string
|
||||||
const modelName = nodeData.inputs?.modelName as string
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
@@ -102,9 +111,9 @@ class GoogleVertexAI_LLMs implements INode {
|
|||||||
|
|
||||||
const obj: Partial<GoogleVertexAITextInput> = {
|
const obj: Partial<GoogleVertexAITextInput> = {
|
||||||
temperature: parseFloat(temperature),
|
temperature: parseFloat(temperature),
|
||||||
model: modelName,
|
model: modelName
|
||||||
authOptions
|
|
||||||
}
|
}
|
||||||
|
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
|
||||||
|
|
||||||
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
||||||
if (topP) obj.topP = parseFloat(topP)
|
if (topP) obj.topP = parseFloat(topP)
|
||||||
|
|||||||
Reference in New Issue
Block a user