From 359d896733f59304eb23ffc28e6c2344343df955 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Fri, 7 Jun 2024 08:08:16 -0400 Subject: [PATCH 1/2] feat: added Vertex AI multilingual embeddings and text-embedding-004 --- js/plugins/vertexai/src/embedder.ts | 34 +++++++++++++++++++++++------ js/plugins/vertexai/src/index.ts | 12 ++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/js/plugins/vertexai/src/embedder.ts b/js/plugins/vertexai/src/embedder.ts index 5de795b06..f14babc5d 100644 --- a/js/plugins/vertexai/src/embedder.ts +++ b/js/plugins/vertexai/src/embedder.ts @@ -81,23 +81,41 @@ export const textEmbeddingGecko001 = embedderRef({ }, }); -/* -// @TODO(huangjeff): Fix multilingual text embedding gecko -// For some reason this model returns 404 but it exists in the reference docs: -// https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-text-embeddings +export const textEmbedding004 = embedderRef({ + name: 'vertexai/text-embedding-004', + configSchema: TextEmbeddingGeckoConfigSchema, + info: { + dimensions: 768, + label: 'Vertex AI - Text Embedding 004', + supports: { + input: ['text'], + }, + }, +}); + +export const textMultilingualEmbedding002 = embedderRef({ + name: 'vertexai/text-multilingual-embedding-002', + configSchema: TextEmbeddingGeckoConfigSchema, + info: { + dimensions: 768, + label: 'Vertex AI - Text Multilingual Embedding 002', + supports: { + input: ['text'], + }, + }, +}); export const textEmbeddingGeckoMultilingual001 = embedderRef({ name: 'vertexai/textembedding-gecko-multilingual@001', configSchema: TextEmbeddingGeckoConfigSchema, info: { dimensions: 768, - label: 'Vertex AI - Multilingual Text Embedding Gecko', + label: 'Vertex AI - Multilingual Text Embedding Gecko 001', supports: { input: ['text'], }, }, }); -*/ export const textEmbeddingGecko = textEmbeddingGecko003; @@ -105,7 +123,9 @@ export const SUPPORTED_EMBEDDER_MODELS: Record = { 'textembedding-gecko@003': textEmbeddingGecko003, 'textembedding-gecko@002': textEmbeddingGecko002, 'textembedding-gecko@001': textEmbeddingGecko001, - //'textembeddding-gecko-multilingual@001': textEmbeddingGeckoMultilingual001, + 'text-embedding-004': textEmbedding004, + 'textembedding-gecko-multilingual@001': textEmbeddingGeckoMultilingual001, + 'text-multilingual-embedding-002': textMultilingualEmbedding002, }; interface EmbeddingInstance { diff --git a/js/plugins/vertexai/src/index.ts b/js/plugins/vertexai/src/index.ts index 8bf134e43..11cb09c47 100644 --- a/js/plugins/vertexai/src/index.ts +++ b/js/plugins/vertexai/src/index.ts @@ -29,6 +29,12 @@ import { SUPPORTED_EMBEDDER_MODELS, textEmbeddingGecko, textEmbeddingGeckoEmbedder, + textEmbeddingGecko001, + textEmbeddingGecko002, + textEmbeddingGecko003, + textEmbedding004, + textEmbeddingGeckoMultilingual001, + textMultilingualEmbedding002, } from './embedder.js'; import { VertexAIEvaluationMetric, @@ -55,6 +61,12 @@ export { geminiProVision, imagen2, textEmbeddingGecko, + textEmbeddingGecko001, + textEmbeddingGecko002, + textEmbeddingGecko003, + textEmbedding004, + textEmbeddingGeckoMultilingual001, + textMultilingualEmbedding002, VertexAIEvaluationMetricType as VertexAIEvaluationMetricType, }; From 16078471f47057649502831d0e4e30f6cfd11fa9 Mon Sep 17 00:00:00 2001 From: Pavel Jbanov Date: Fri, 7 Jun 2024 08:08:46 -0400 Subject: [PATCH 2/2] format --- js/plugins/vertexai/src/embedder.ts | 2 +- js/plugins/vertexai/src/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/plugins/vertexai/src/embedder.ts b/js/plugins/vertexai/src/embedder.ts index f14babc5d..072464409 100644 --- a/js/plugins/vertexai/src/embedder.ts +++ b/js/plugins/vertexai/src/embedder.ts @@ -93,7 +93,7 @@ export const textEmbedding004 = embedderRef({ }, }); -export const textMultilingualEmbedding002 = embedderRef({ +export const textMultilingualEmbedding002 = embedderRef({ name: 'vertexai/text-multilingual-embedding-002', configSchema: TextEmbeddingGeckoConfigSchema, info: { diff --git a/js/plugins/vertexai/src/index.ts b/js/plugins/vertexai/src/index.ts index 11cb09c47..acba0bce6 100644 --- a/js/plugins/vertexai/src/index.ts +++ b/js/plugins/vertexai/src/index.ts @@ -27,12 +27,12 @@ import { } from './anthropic.js'; import { SUPPORTED_EMBEDDER_MODELS, + textEmbedding004, textEmbeddingGecko, - textEmbeddingGeckoEmbedder, textEmbeddingGecko001, textEmbeddingGecko002, textEmbeddingGecko003, - textEmbedding004, + textEmbeddingGeckoEmbedder, textEmbeddingGeckoMultilingual001, textMultilingualEmbedding002, } from './embedder.js'; @@ -60,11 +60,11 @@ export { geminiPro, geminiProVision, imagen2, + textEmbedding004, textEmbeddingGecko, textEmbeddingGecko001, textEmbeddingGecko002, textEmbeddingGecko003, - textEmbedding004, textEmbeddingGeckoMultilingual001, textMultilingualEmbedding002, VertexAIEvaluationMetricType as VertexAIEvaluationMetricType,