Added region support to chatGoogleVertexAi (#4839)

* Added region support to chatGoogleVertexAi

* Added region to the vertex ai embeddings loader too

* Updated the available vertex text embedding models to be valid

* Update ChatGoogleVertexAI.ts

* Update GoogleVertexAIEmbedding.ts

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
Karl Stoney
2025-07-18 11:28:23 +01:00
committed by GitHub
parent cf965f3d8e
commit 5e5b2a18e2
3 changed files with 127 additions and 21 deletions
@@ -1,5 +1,5 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatVertexAI as LcChatVertexAI, ChatVertexAIInput } from '@langchain/google-vertexai'
import { ChatVertexAIInput, ChatVertexAI as LcChatVertexAI } from '@langchain/google-vertexai'
import {
ICommonObject,
IMultiModalOption,
@@ -9,8 +9,8 @@ import {
INodeParams,
IVisionChatModal
} from '../../../src/Interface'
import { getModels, getRegions, MODEL_TYPE } from '../../../src/modelLoader'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
const DEFAULT_IMAGE_MAX_TOKEN = 8192
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
@@ -65,7 +65,7 @@ class GoogleVertexAI_ChatModels implements INode {
constructor() {
this.label = 'ChatGoogleVertexAI'
this.name = 'chatGoogleVertexAI'
this.version = 5.2
this.version = 5.3
this.type = 'ChatGoogleVertexAI'
this.icon = 'GoogleVertex.svg'
this.category = 'Chat Models'
@@ -87,6 +87,14 @@ class GoogleVertexAI_ChatModels implements INode {
type: 'BaseCache',
optional: true
},
{
label: 'Region',
description: 'Region to use for the model.',
name: 'region',
type: 'asyncOptions',
loadMethod: 'listRegions',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
@@ -169,6 +177,9 @@ class GoogleVertexAI_ChatModels implements INode {
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.CHAT, 'chatGoogleVertexAI')
},
async listRegions(): Promise<INodeOptionsValue[]> {
return await getRegions(MODEL_TYPE.CHAT, 'chatGoogleVertexAI')
}
}
@@ -203,6 +214,7 @@ class GoogleVertexAI_ChatModels implements INode {
const topK = nodeData.inputs?.topK as string
const streaming = nodeData.inputs?.streaming as boolean
const thinkingBudget = nodeData.inputs?.thinkingBudget as string
const region = nodeData.inputs?.region as string
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
@@ -223,6 +235,7 @@ class GoogleVertexAI_ChatModels implements INode {
if (cache) obj.cache = cache
if (topK) obj.topK = parseFloat(topK)
if (thinkingBudget) obj.thinkingBudget = parseInt(thinkingBudget, 10)
if (region) obj.location = region
const model = new ChatVertexAI(nodeData.id, obj)
model.setMultiModalOption(multiModalOption)