Skip to content

Commit 2df129f

Browse files
authored
Vertex Gemini Custom Model Changes (#3737)
1 parent e8903a5 commit 2df129f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/components/nodes/chatmodels/ChatGoogleVertexAI/ChatGoogleVertexAI.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class ChatVertexAI extends LcChatVertexAI implements IVisionChatModal {
2323

2424
constructor(id: string, fields?: ChatVertexAIInput) {
2525
// @ts-ignore
26+
if (fields?.model) {
27+
fields.modelName = fields.model
28+
delete fields.model
29+
}
2630
super(fields ?? {})
2731
this.id = id
2832
this.configuredModel = fields?.modelName || ''
@@ -61,7 +65,7 @@ class GoogleVertexAI_ChatModels implements INode {
6165
constructor() {
6266
this.label = 'ChatGoogleVertexAI'
6367
this.name = 'chatGoogleVertexAI'
64-
this.version = 5.0
68+
this.version = 5.1
6569
this.type = 'ChatGoogleVertexAI'
6670
this.icon = 'GoogleVertex.svg'
6771
this.category = 'Chat Models'
@@ -89,6 +93,14 @@ class GoogleVertexAI_ChatModels implements INode {
8993
type: 'asyncOptions',
9094
loadMethod: 'listModels'
9195
},
96+
{
97+
label: 'Custom Model Name',
98+
name: 'customModelName',
99+
type: 'string',
100+
placeholder: 'gemini-1.5-pro-exp-0801',
101+
description: 'Custom model name to use. If provided, it will override the model selected',
102+
additionalParams: true
103+
},
92104
{
93105
label: 'Temperature',
94106
name: 'temperature',
@@ -163,7 +175,6 @@ class GoogleVertexAI_ChatModels implements INode {
163175
throw new Error(
164176
'Error: More than one component has been inputted. Please use only one of the following: Google Application Credential File Path or Google Credential JSON Object'
165177
)
166-
167178
if (googleApplicationCredentialFilePath && !googleApplicationCredential)
168179
authOptions.keyFile = googleApplicationCredentialFilePath
169180
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
@@ -174,6 +185,7 @@ class GoogleVertexAI_ChatModels implements INode {
174185

175186
const temperature = nodeData.inputs?.temperature as string
176187
const modelName = nodeData.inputs?.modelName as string
188+
const customModelName = nodeData.inputs?.customModelName as string
177189
const maxOutputTokens = nodeData.inputs?.maxOutputTokens as string
178190
const topP = nodeData.inputs?.topP as string
179191
const cache = nodeData.inputs?.cache as BaseCache
@@ -190,11 +202,10 @@ class GoogleVertexAI_ChatModels implements INode {
190202

191203
const obj: ChatVertexAIInput = {
192204
temperature: parseFloat(temperature),
193-
model: modelName,
205+
modelName: customModelName || modelName,
194206
streaming: streaming ?? true
195207
}
196208
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
197-
198209
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
199210
if (topP) obj.topP = parseFloat(topP)
200211
if (cache) obj.cache = cache

0 commit comments

Comments
 (0)