From 30f9c033db28112e1f97bb55d41b5bfce265cb51 Mon Sep 17 00:00:00 2001 From: Eugene Date: Tue, 7 Jan 2025 15:09:59 +0100 Subject: [PATCH] feat(Google Vertex Chat Model Node): Add an option to specify GCP region (#12300) --- cypress/pages/modals/credentials-modal.ts | 1 + .../LmChatGoogleVertex.node.ts | 2 + .../credentials/GoogleApi.credentials.ts | 220 ++++++++++++++++++ 3 files changed, 223 insertions(+) diff --git a/cypress/pages/modals/credentials-modal.ts b/cypress/pages/modals/credentials-modal.ts index b8907386a0..ac8e966bc0 100644 --- a/cypress/pages/modals/credentials-modal.ts +++ b/cypress/pages/modals/credentials-modal.ts @@ -61,6 +61,7 @@ export class CredentialsModal extends BasePage { this.getters .credentialInputs() .find('input[type=text], input[type=password]') + .filter(':not([readonly])') .each(($el) => { cy.wrap($el).type('test'); }); diff --git a/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts b/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts index 5ca6091378..ab3320c2ba 100644 --- a/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts @@ -131,6 +131,7 @@ export class LmChatGoogleVertex implements INodeType { const credentials = await this.getCredentials('googleApi'); const privateKey = formatPrivateKey(credentials.privateKey as string); const email = (credentials.email as string).trim(); + const region = credentials.region as string; const modelName = this.getNodeParameter('modelName', itemIndex) as string; @@ -165,6 +166,7 @@ export class LmChatGoogleVertex implements INodeType { private_key: privateKey, }, }, + location: region, model: modelName, topK: options.topK, topP: options.topP, diff --git a/packages/nodes-base/credentials/GoogleApi.credentials.ts b/packages/nodes-base/credentials/GoogleApi.credentials.ts index 38df5ac694..73863c7952 100644 --- a/packages/nodes-base/credentials/GoogleApi.credentials.ts +++ b/packages/nodes-base/credentials/GoogleApi.credentials.ts @@ -10,6 +10,214 @@ import type { Icon, } from 'n8n-workflow'; +const regions = [ + { + name: 'africa-south1', + displayName: 'Africa', + location: 'Johannesburg', + }, + { + name: 'asia-east1', + displayName: 'Asia Pacific', + location: 'Changhua County', + }, + { + name: 'asia-east2', + displayName: 'Asia Pacific', + location: 'Hong Kong', + }, + { + name: 'asia-northeast1', + displayName: 'Asia Pacific', + location: 'Tokyo', + }, + { + name: 'asia-northeast2', + displayName: 'Asia Pacific', + location: 'Osaka', + }, + { + name: 'asia-northeast3', + displayName: 'Asia Pacific', + location: 'Seoul', + }, + { + name: 'asia-south1', + displayName: 'Asia Pacific', + location: 'Mumbai', + }, + { + name: 'asia-south2', + displayName: 'Asia Pacific', + location: 'Delhi', + }, + { + name: 'asia-southeast1', + displayName: 'Asia Pacific', + location: 'Jurong West', + }, + { + name: 'asia-southeast2', + displayName: 'Asia Pacific', + location: 'Jakarta', + }, + { + name: 'australia-southeast1', + displayName: 'Asia Pacific', + location: 'Sydney', + }, + { + name: 'australia-southeast2', + displayName: 'Asia Pacific', + location: 'Melbourne', + }, + { + name: 'europe-central2', + displayName: 'Europe', + location: 'Warsaw', + }, + { + name: 'europe-north1', + displayName: 'Europe', + location: 'Hamina', + }, + { + name: 'europe-southwest1', + displayName: 'Europe', + location: 'Madrid', + }, + { + name: 'europe-west1', + displayName: 'Europe', + location: 'St. Ghislain', + }, + { + name: 'europe-west10', + displayName: 'Europe', + location: 'Berlin', + }, + { + name: 'europe-west12', + displayName: 'Europe', + location: 'Turin', + }, + { + name: 'europe-west2', + displayName: 'Europe', + location: 'London', + }, + { + name: 'europe-west3', + displayName: 'Europe', + location: 'Frankfurt', + }, + { + name: 'europe-west4', + displayName: 'Europe', + location: 'Eemshaven', + }, + { + name: 'europe-west6', + displayName: 'Europe', + location: 'Zurich', + }, + { + name: 'europe-west8', + displayName: 'Europe', + location: 'Milan', + }, + { + name: 'europe-west9', + displayName: 'Europe', + location: 'Paris', + }, + { + name: 'me-central1', + displayName: 'Middle East', + location: 'Doha', + }, + { + name: 'me-central2', + displayName: 'Middle East', + location: 'Dammam', + }, + { + name: 'me-west1', + displayName: 'Middle East', + location: 'Tel Aviv', + }, + { + name: 'northamerica-northeast1', + displayName: 'Americas', + location: 'Montréal', + }, + { + name: 'northamerica-northeast2', + displayName: 'Americas', + location: 'Toronto', + }, + { + name: 'northamerica-south1', + displayName: 'Americas', + location: 'Queretaro', + }, + { + name: 'southamerica-east1', + displayName: 'Americas', + location: 'Osasco', + }, + { + name: 'southamerica-west1', + displayName: 'Americas', + location: 'Santiago', + }, + { + name: 'us-central1', + displayName: 'Americas', + location: 'Council Bluffs', + }, + { + name: 'us-east1', + displayName: 'Americas', + location: 'Moncks Corner', + }, + { + name: 'us-east4', + displayName: 'Americas', + location: 'Ashburn', + }, + { + name: 'us-east5', + displayName: 'Americas', + location: 'Columbus', + }, + { + name: 'us-south1', + displayName: 'Americas', + location: 'Dallas', + }, + { + name: 'us-west1', + displayName: 'Americas', + location: 'The Dalles', + }, + { + name: 'us-west2', + displayName: 'Americas', + location: 'Los Angeles', + }, + { + name: 'us-west3', + displayName: 'Americas', + location: 'Salt Lake City', + }, + { + name: 'us-west4', + displayName: 'Americas', + location: 'Las Vegas', + }, +] as const; + export class GoogleApi implements ICredentialType { name = 'googleApi'; @@ -20,6 +228,18 @@ export class GoogleApi implements ICredentialType { icon: Icon = 'file:icons/Google.svg'; properties: INodeProperties[] = [ + { + displayName: 'Region', + name: 'region', + type: 'options', + options: regions.map((r) => ({ + name: `${r.displayName} (${r.location}) - ${r.name}`, + value: r.name, + })), + default: 'us-central1', + description: + 'The region where the Google Cloud service is located. This applies only to specific nodes, like the Google Vertex Chat Model', + }, { displayName: 'Service Account Email', name: 'email',