From f3becd059730a03e75213e5751604290513db9ec Mon Sep 17 00:00:00 2001 From: Eugene Molodkin Date: Wed, 11 Sep 2024 15:25:29 +0200 Subject: [PATCH] wip: Use utility function to clean up a key --- .../nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts b/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts index e94343cdefe1a..55ccda90d20e9 100644 --- a/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.ts @@ -12,6 +12,7 @@ import { import { ChatVertexAI } from '@langchain/google-vertexai'; import type { SafetySetting } from '@google/generative-ai'; import { ProjectsClient } from '@google-cloud/resource-manager'; +import { formatPrivateKey } from 'n8n-nodes-base/dist/utils/utilities'; import { getConnectionHintNoticeField } from '../../../utils/sharedFields'; import { N8nLlmTracing } from '../N8nLlmTracing'; import { additionalOptions } from '../gemini-common/additional-options'; @@ -97,7 +98,7 @@ export class LmChatGoogleVertex implements INodeType { const results: Array<{ name: string; value: string }> = []; const credentials = await this.getCredentials('googleApi'); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = formatPrivateKey(credentials.privateKey as string); const email = (credentials.email as string).trim(); const client = new ProjectsClient({ @@ -125,7 +126,7 @@ export class LmChatGoogleVertex implements INodeType { async supplyData(this: IExecuteFunctions, itemIndex: number): Promise { const credentials = await this.getCredentials('googleApi'); - const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); + const privateKey = formatPrivateKey(credentials.privateKey as string); const email = (credentials.email as string).trim(); const modelName = this.getNodeParameter('modelName', itemIndex) as string;