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:
parent
cf965f3d8e
commit
5e5b2a18e2
|
|
@ -697,6 +697,50 @@
|
||||||
"input_cost": 2.5e-7,
|
"input_cost": 2.5e-7,
|
||||||
"output_cost": 1.25e-6
|
"output_cost": 1.25e-6
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"regions": [
|
||||||
|
{ "label": "us-east1", "name": "us-east1" },
|
||||||
|
{ "label": "us-east4", "name": "us-east4" },
|
||||||
|
{ "label": "us-central1", "name": "us-central1" },
|
||||||
|
{ "label": "us-west1", "name": "us-west1" },
|
||||||
|
{ "label": "europe-west4", "name": "europe-west4" },
|
||||||
|
{ "label": "europe-west1", "name": "europe-west1" },
|
||||||
|
{ "label": "europe-west3", "name": "europe-west3" },
|
||||||
|
{ "label": "europe-west2", "name": "europe-west2" },
|
||||||
|
{ "label": "asia-east1", "name": "asia-east1" },
|
||||||
|
{ "label": "asia-southeast1", "name": "asia-southeast1" },
|
||||||
|
{ "label": "asia-northeast1", "name": "asia-northeast1" },
|
||||||
|
{ "label": "asia-south1", "name": "asia-south1" },
|
||||||
|
{ "label": "australia-southeast1", "name": "australia-southeast1" },
|
||||||
|
{ "label": "southamerica-east1", "name": "southamerica-east1" },
|
||||||
|
{ "label": "africa-south1", "name": "africa-south1" },
|
||||||
|
{ "label": "asia-east2", "name": "asia-east2" },
|
||||||
|
{ "label": "asia-northeast2", "name": "asia-northeast2" },
|
||||||
|
{ "label": "asia-northeast3", "name": "asia-northeast3" },
|
||||||
|
{ "label": "asia-south2", "name": "asia-south2" },
|
||||||
|
{ "label": "asia-southeast2", "name": "asia-southeast2" },
|
||||||
|
{ "label": "australia-southeast2", "name": "australia-southeast2" },
|
||||||
|
{ "label": "europe-central2", "name": "europe-central2" },
|
||||||
|
{ "label": "europe-north1", "name": "europe-north1" },
|
||||||
|
{ "label": "europe-north2", "name": "europe-north2" },
|
||||||
|
{ "label": "europe-southwest1", "name": "europe-southwest1" },
|
||||||
|
{ "label": "europe-west10", "name": "europe-west10" },
|
||||||
|
{ "label": "europe-west12", "name": "europe-west12" },
|
||||||
|
{ "label": "europe-west6", "name": "europe-west6" },
|
||||||
|
{ "label": "europe-west8", "name": "europe-west8" },
|
||||||
|
{ "label": "europe-west9", "name": "europe-west9" },
|
||||||
|
{ "label": "me-central1", "name": "me-central1" },
|
||||||
|
{ "label": "me-central2", "name": "me-central2" },
|
||||||
|
{ "label": "me-west1", "name": "me-west1" },
|
||||||
|
{ "label": "northamerica-northeast1", "name": "northamerica-northeast1" },
|
||||||
|
{ "label": "northamerica-northeast2", "name": "northamerica-northeast2" },
|
||||||
|
{ "label": "northamerica-south1", "name": "northamerica-south1" },
|
||||||
|
{ "label": "southamerica-west1", "name": "southamerica-west1" },
|
||||||
|
{ "label": "us-east5", "name": "us-east5" },
|
||||||
|
{ "label": "us-south1", "name": "us-south1" },
|
||||||
|
{ "label": "us-west2", "name": "us-west2" },
|
||||||
|
{ "label": "us-west3", "name": "us-west3" },
|
||||||
|
{ "label": "us-west4", "name": "us-west4" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -1747,29 +1791,65 @@
|
||||||
"name": "googlevertexaiEmbeddings",
|
"name": "googlevertexaiEmbeddings",
|
||||||
"models": [
|
"models": [
|
||||||
{
|
{
|
||||||
"label": "multimodalembedding",
|
"label": "gemini-embedding-001",
|
||||||
"name": "multimodalembedding"
|
"name": "gemini-embedding-001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "text-embedding-004",
|
"label": "text-embedding-004",
|
||||||
"name": "text-embedding-004"
|
"name": "text-embedding-004"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "text-embedding-005",
|
||||||
|
"name": "text-embedding-005"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "text-multilingual-embedding-002",
|
"label": "text-multilingual-embedding-002",
|
||||||
"name": "text-multilingual-embedding-002"
|
"name": "text-multilingual-embedding-002"
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "textembedding-gecko@001",
|
|
||||||
"name": "textembedding-gecko@001"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "textembedding-gecko@latest",
|
|
||||||
"name": "textembedding-gecko@latest"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "textembedding-gecko-multilingual@latest",
|
|
||||||
"name": "textembedding-gecko-multilingual@latest"
|
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"regions": [
|
||||||
|
{ "label": "us-east1", "name": "us-east1" },
|
||||||
|
{ "label": "us-east4", "name": "us-east4" },
|
||||||
|
{ "label": "us-central1", "name": "us-central1" },
|
||||||
|
{ "label": "us-west1", "name": "us-west1" },
|
||||||
|
{ "label": "europe-west4", "name": "europe-west4" },
|
||||||
|
{ "label": "europe-west1", "name": "europe-west1" },
|
||||||
|
{ "label": "europe-west3", "name": "europe-west3" },
|
||||||
|
{ "label": "europe-west2", "name": "europe-west2" },
|
||||||
|
{ "label": "asia-east1", "name": "asia-east1" },
|
||||||
|
{ "label": "asia-southeast1", "name": "asia-southeast1" },
|
||||||
|
{ "label": "asia-northeast1", "name": "asia-northeast1" },
|
||||||
|
{ "label": "asia-south1", "name": "asia-south1" },
|
||||||
|
{ "label": "australia-southeast1", "name": "australia-southeast1" },
|
||||||
|
{ "label": "southamerica-east1", "name": "southamerica-east1" },
|
||||||
|
{ "label": "africa-south1", "name": "africa-south1" },
|
||||||
|
{ "label": "asia-east2", "name": "asia-east2" },
|
||||||
|
{ "label": "asia-northeast2", "name": "asia-northeast2" },
|
||||||
|
{ "label": "asia-northeast3", "name": "asia-northeast3" },
|
||||||
|
{ "label": "asia-south2", "name": "asia-south2" },
|
||||||
|
{ "label": "asia-southeast2", "name": "asia-southeast2" },
|
||||||
|
{ "label": "australia-southeast2", "name": "australia-southeast2" },
|
||||||
|
{ "label": "europe-central2", "name": "europe-central2" },
|
||||||
|
{ "label": "europe-north1", "name": "europe-north1" },
|
||||||
|
{ "label": "europe-north2", "name": "europe-north2" },
|
||||||
|
{ "label": "europe-southwest1", "name": "europe-southwest1" },
|
||||||
|
{ "label": "europe-west10", "name": "europe-west10" },
|
||||||
|
{ "label": "europe-west12", "name": "europe-west12" },
|
||||||
|
{ "label": "europe-west6", "name": "europe-west6" },
|
||||||
|
{ "label": "europe-west8", "name": "europe-west8" },
|
||||||
|
{ "label": "europe-west9", "name": "europe-west9" },
|
||||||
|
{ "label": "me-central1", "name": "me-central1" },
|
||||||
|
{ "label": "me-central2", "name": "me-central2" },
|
||||||
|
{ "label": "me-west1", "name": "me-west1" },
|
||||||
|
{ "label": "northamerica-northeast1", "name": "northamerica-northeast1" },
|
||||||
|
{ "label": "northamerica-northeast2", "name": "northamerica-northeast2" },
|
||||||
|
{ "label": "northamerica-south1", "name": "northamerica-south1" },
|
||||||
|
{ "label": "southamerica-west1", "name": "southamerica-west1" },
|
||||||
|
{ "label": "us-east5", "name": "us-east5" },
|
||||||
|
{ "label": "us-south1", "name": "us-south1" },
|
||||||
|
{ "label": "us-west2", "name": "us-west2" },
|
||||||
|
{ "label": "us-west3", "name": "us-west3" },
|
||||||
|
{ "label": "us-west4", "name": "us-west4" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseCache } from '@langchain/core/caches'
|
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 {
|
import {
|
||||||
ICommonObject,
|
ICommonObject,
|
||||||
IMultiModalOption,
|
IMultiModalOption,
|
||||||
|
|
@ -9,8 +9,8 @@ import {
|
||||||
INodeParams,
|
INodeParams,
|
||||||
IVisionChatModal
|
IVisionChatModal
|
||||||
} from '../../../src/Interface'
|
} from '../../../src/Interface'
|
||||||
|
import { getModels, getRegions, MODEL_TYPE } from '../../../src/modelLoader'
|
||||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
|
|
||||||
|
|
||||||
const DEFAULT_IMAGE_MAX_TOKEN = 8192
|
const DEFAULT_IMAGE_MAX_TOKEN = 8192
|
||||||
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
|
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
|
||||||
|
|
@ -65,7 +65,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'ChatGoogleVertexAI'
|
this.label = 'ChatGoogleVertexAI'
|
||||||
this.name = 'chatGoogleVertexAI'
|
this.name = 'chatGoogleVertexAI'
|
||||||
this.version = 5.2
|
this.version = 5.3
|
||||||
this.type = 'ChatGoogleVertexAI'
|
this.type = 'ChatGoogleVertexAI'
|
||||||
this.icon = 'GoogleVertex.svg'
|
this.icon = 'GoogleVertex.svg'
|
||||||
this.category = 'Chat Models'
|
this.category = 'Chat Models'
|
||||||
|
|
@ -87,6 +87,14 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||||
type: 'BaseCache',
|
type: 'BaseCache',
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Region',
|
||||||
|
description: 'Region to use for the model.',
|
||||||
|
name: 'region',
|
||||||
|
type: 'asyncOptions',
|
||||||
|
loadMethod: 'listRegions',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Model Name',
|
label: 'Model Name',
|
||||||
name: 'modelName',
|
name: 'modelName',
|
||||||
|
|
@ -169,6 +177,9 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||||
loadMethods = {
|
loadMethods = {
|
||||||
async listModels(): Promise<INodeOptionsValue[]> {
|
async listModels(): Promise<INodeOptionsValue[]> {
|
||||||
return await getModels(MODEL_TYPE.CHAT, 'chatGoogleVertexAI')
|
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 topK = nodeData.inputs?.topK as string
|
||||||
const streaming = nodeData.inputs?.streaming as boolean
|
const streaming = nodeData.inputs?.streaming as boolean
|
||||||
const thinkingBudget = nodeData.inputs?.thinkingBudget as string
|
const thinkingBudget = nodeData.inputs?.thinkingBudget as string
|
||||||
|
const region = nodeData.inputs?.region as string
|
||||||
|
|
||||||
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
|
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
|
||||||
|
|
||||||
|
|
@ -223,6 +235,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||||
if (cache) obj.cache = cache
|
if (cache) obj.cache = cache
|
||||||
if (topK) obj.topK = parseFloat(topK)
|
if (topK) obj.topK = parseFloat(topK)
|
||||||
if (thinkingBudget) obj.thinkingBudget = parseInt(thinkingBudget, 10)
|
if (thinkingBudget) obj.thinkingBudget = parseInt(thinkingBudget, 10)
|
||||||
|
if (region) obj.location = region
|
||||||
|
|
||||||
const model = new ChatVertexAI(nodeData.id, obj)
|
const model = new ChatVertexAI(nodeData.id, obj)
|
||||||
model.setMultiModalOption(multiModalOption)
|
model.setMultiModalOption(multiModalOption)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { VertexAIEmbeddings, GoogleVertexAIEmbeddingsInput } from '@langchain/google-vertexai'
|
import { GoogleVertexAIEmbeddingsInput, VertexAIEmbeddings } from '@langchain/google-vertexai'
|
||||||
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
|
||||||
|
import { MODEL_TYPE, getModels, getRegions } from '../../../src/modelLoader'
|
||||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
|
|
||||||
|
|
||||||
class GoogleVertexAIEmbedding_Embeddings implements INode {
|
class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -18,7 +18,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'GoogleVertexAI Embeddings'
|
this.label = 'GoogleVertexAI Embeddings'
|
||||||
this.name = 'googlevertexaiEmbeddings'
|
this.name = 'googlevertexaiEmbeddings'
|
||||||
this.version = 2.0
|
this.version = 2.1
|
||||||
this.type = 'GoogleVertexAIEmbeddings'
|
this.type = 'GoogleVertexAIEmbeddings'
|
||||||
this.icon = 'GoogleVertex.svg'
|
this.icon = 'GoogleVertex.svg'
|
||||||
this.category = 'Embeddings'
|
this.category = 'Embeddings'
|
||||||
|
|
@ -39,7 +39,15 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||||
name: 'modelName',
|
name: 'modelName',
|
||||||
type: 'asyncOptions',
|
type: 'asyncOptions',
|
||||||
loadMethod: 'listModels',
|
loadMethod: 'listModels',
|
||||||
default: 'textembedding-gecko@001'
|
default: 'text-embedding-004'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Region',
|
||||||
|
description: 'Region to use for the model.',
|
||||||
|
name: 'region',
|
||||||
|
type: 'asyncOptions',
|
||||||
|
loadMethod: 'listRegions',
|
||||||
|
optional: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +56,16 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||||
loadMethods = {
|
loadMethods = {
|
||||||
async listModels(): Promise<INodeOptionsValue[]> {
|
async listModels(): Promise<INodeOptionsValue[]> {
|
||||||
return await getModels(MODEL_TYPE.EMBEDDING, 'googlevertexaiEmbeddings')
|
return await getModels(MODEL_TYPE.EMBEDDING, 'googlevertexaiEmbeddings')
|
||||||
|
},
|
||||||
|
async listRegions(): Promise<INodeOptionsValue[]> {
|
||||||
|
return await getRegions(MODEL_TYPE.EMBEDDING, 'googlevertexaiEmbeddings')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const modelName = nodeData.inputs?.modelName as string
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
|
const region = nodeData.inputs?.region as string
|
||||||
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
||||||
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
|
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
|
||||||
const projectID = getCredentialParam('projectID', credentialData, nodeData)
|
const projectID = getCredentialParam('projectID', credentialData, nodeData)
|
||||||
|
|
@ -78,6 +90,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||||
model: modelName
|
model: modelName
|
||||||
}
|
}
|
||||||
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
|
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
|
||||||
|
if (region) obj.location = region
|
||||||
|
|
||||||
const model = new VertexAIEmbeddings(obj)
|
const model = new VertexAIEmbeddings(obj)
|
||||||
return model
|
return model
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue