diff --git a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts index 836f97039..93fbad994 100644 --- a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts +++ b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/ChatGoogleGenerativeAI.ts @@ -163,6 +163,14 @@ class GoogleGenerativeAI_ChatModels implements INode { optional: true, additionalParams: true }, + { + label: 'Base URL', + name: 'baseUrl', + type: 'string', + description: 'Base URL for the API. Leave empty to use the default.', + optional: true, + additionalParams: true + }, { label: 'Allow Image Uploads', name: 'allowImageUploads', @@ -197,6 +205,7 @@ class GoogleGenerativeAI_ChatModels implements INode { const cache = nodeData.inputs?.cache as BaseCache const contextCache = nodeData.inputs?.contextCache as FlowiseGoogleAICacheManager const streaming = nodeData.inputs?.streaming as boolean + const baseUrl = nodeData.inputs?.baseUrl as string | undefined const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean @@ -211,6 +220,7 @@ class GoogleGenerativeAI_ChatModels implements INode { if (topK) obj.topK = parseFloat(topK) if (cache) obj.cache = cache if (temperature) obj.temperature = parseFloat(temperature) + if (baseUrl) obj.baseUrl = baseUrl // Safety Settings let harmCategories: string[] = convertMultiOptionsToStringArray(harmCategory) diff --git a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts index 49a97e752..4824810eb 100644 --- a/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts +++ b/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts @@ -81,6 +81,8 @@ class LangchainChatGoogleGenerativeAI apiKey?: string + baseUrl?: string + streaming = false streamUsage = true @@ -151,19 +153,24 @@ class LangchainChatGoogleGenerativeAI } async getClient(prompt?: Content[], tools?: Tool[]) { - this.client = new GenerativeAI(this.apiKey ?? '').getGenerativeModel({ - model: this.modelName, - tools, - safetySettings: this.safetySettings as SafetySetting[], - generationConfig: { - candidateCount: 1, - stopSequences: this.stopSequences, - maxOutputTokens: this.maxOutputTokens, - temperature: this.temperature, - topP: this.topP, - topK: this.topK + this.client = new GenerativeAI(this.apiKey ?? '').getGenerativeModel( + { + model: this.modelName, + tools, + safetySettings: this.safetySettings as SafetySetting[], + generationConfig: { + candidateCount: 1, + stopSequences: this.stopSequences, + maxOutputTokens: this.maxOutputTokens, + temperature: this.temperature, + topP: this.topP, + topK: this.topK + } + }, + { + baseUrl: this.baseUrl } - }) + ) if (this.contextCache) { const cachedContent = await this.contextCache.lookup({ contents: prompt ? [{ ...prompt[0], parts: prompt[0].parts.slice(0, 1) }] : [],