Skip to content

Commit

Permalink
wip: Add region setting for Google API credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
burivuhster committed Dec 19, 2024
1 parent 882484e commit 8cd609e
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 0 deletions.
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
219 changes: 219 additions & 0 deletions packages/nodes-base/credentials/GoogleApi.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,214 @@ import type { AxiosRequestConfig } from 'axios';

import axios from 'axios';

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 @@ -24,6 +232,17 @@ 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',
},
{
displayName: 'Service Account Email',
name: 'email',
Expand Down

0 comments on commit 8cd609e

Please sign in to comment.