Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Google Vertex Chat Model Node): Add an option to specify GCP region #12300

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -165,6 +166,7 @@ export class LmChatGoogleVertex implements INodeType {
private_key: privateKey,
},
},
location: region,
model: modelName,
topK: options.topK,
topP: options.topP,
Expand Down
220 changes: 220 additions & 0 deletions packages/nodes-base/credentials/GoogleApi.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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',
Expand Down
Loading