From a05d73d83b245e29cc51d723c8d998aa445923eb Mon Sep 17 00:00:00 2001 From: Yongtae Date: Sun, 3 Sep 2023 19:12:42 +0900 Subject: [PATCH 1/4] Add input option for Model Name in GoogleVertexAIEmbedding --- .../GoogleVertexAIEmbedding.ts | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts index fdf7ea978..ad86ff5f7 100644 --- a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts +++ b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts @@ -33,11 +33,35 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { description: 'Google Vertex AI credential. If you are using a GCP service like Cloud Run, or if you have installed default credentials on your local machine, you do not need to set this credential.' } - this.inputs = [] + this.inputs = [ + { + label: 'Model Name', + name: 'modelName', + type: 'options', + options: [ + { + 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' + } + ], + default: 'textembedding-gecko@001', + optional: true, + additionalParams: true + } + ] } async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const modelName = nodeData.inputs?.modelName ?? 'textembedding-gecko@001' const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData) @@ -58,7 +82,9 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { if (projectID) authOptions.projectId = projectID } - const obj: GoogleVertexAIEmbeddingsParams = {} + const obj: GoogleVertexAIEmbeddingsParams = { + model: modelName + } if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions const model = new GoogleVertexAIEmbeddings(obj) From 0b67afe54667744d8f3895eaeccc02bf04facb4a Mon Sep 17 00:00:00 2001 From: Yongtae Date: Sun, 3 Sep 2023 19:16:45 +0900 Subject: [PATCH 2/4] Refactor modelName assignment in GoogleVertexAIEmbedding.ts --- .../GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts index ad86ff5f7..61518ceb9 100644 --- a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts +++ b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts @@ -61,7 +61,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { const credentialData = await getCredentialData(nodeData.credential ?? '', options) - const modelName = nodeData.inputs?.modelName ?? 'textembedding-gecko@001' + const modelName = nodeData.inputs?.modelName as string const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData) From 95740a84647d597b96ef8d9b78e21d7761874164 Mon Sep 17 00:00:00 2001 From: Yongtae Date: Mon, 4 Sep 2023 11:01:56 +0900 Subject: [PATCH 3/4] Refactor GoogleVertexAIEmbedding.ts to remove unnecessary additionalParams field --- .../GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts index 61518ceb9..3cbd600a7 100644 --- a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts +++ b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts @@ -53,8 +53,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { } ], default: 'textembedding-gecko@001', - optional: true, - additionalParams: true + optional: true } ] } From a373422abf93fdb2ca92d52f5c9e4dc42f008fde Mon Sep 17 00:00:00 2001 From: Yongtae Date: Mon, 4 Sep 2023 11:02:35 +0900 Subject: [PATCH 4/4] Refactor GoogleVertexAIEmbedding.ts for handling modelName in GoogleVertexAIEmbeddingsParams --- .../GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts index 3cbd600a7..7d086e0cd 100644 --- a/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts +++ b/packages/components/nodes/embeddings/GoogleVertexAIEmbedding/GoogleVertexAIEmbedding.ts @@ -81,9 +81,8 @@ class GoogleVertexAIEmbedding_Embeddings implements INode { if (projectID) authOptions.projectId = projectID } - const obj: GoogleVertexAIEmbeddingsParams = { - model: modelName - } + const obj: GoogleVertexAIEmbeddingsParams = {} + if (modelName) obj.model = modelName if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions const model = new GoogleVertexAIEmbeddings(obj)