The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
(bug-fix) : fix VertexAI missing configurations (#1926)
Divyanshu Prasadd107b639b3e2
diff --git a/docs/mint.json b/docs/mint.jsonindex 5e301898b..1b9825800 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -126,6 +126,7 @@"components/embedders/models/azure_openai","components/embedders/models/ollama","components/embedders/models/huggingface",+ "components/embedders/models/vertexai","components/embedders/models/gemini"]}@@ -231,4 +232,4 @@"apiHost": "https://us.i.posthog.com"}}-}\ No newline at end of file+}diff --git a/mem0/configs/embeddings/base.py b/mem0/configs/embeddings/base.pyindex 632458729..a3d989ee1 100644--- a/mem0/configs/embeddings/base.py+++ b/mem0/configs/embeddings/base.py@@ -25,6 +25,8 @@ class BaseEmbedderConfig(ABC):# AzureOpenAI specificazure_kwargs: Optional[AzureConfig] = {},http_client_proxies: Optional[Union[Dict, str]] = None,+ # VertexAI specific+ vertex_credentials_json: Optional[str] = None,):"""Initializes a configuration class instance for the Embeddings.@@ -63,3 +65,6 @@ class BaseEmbedderConfig(ABC):# AzureOpenAI specificself.azure_kwargs = AzureConfig(**azure_kwargs) or {}++ # VertexAI specific+ self.vertex_credentials_json = vertex_credentials_jsondiff --git a/mem0/embeddings/vertexai.py b/mem0/embeddings/vertexai.pyindex bcdaaab28..740e63030 100644--- a/mem0/embeddings/vertexai.py+++ b/mem0/embeddings/vertexai.py@@ -7,7 +7,7 @@ from mem0.configs.embeddings.base import BaseEmbedderConfigfrom mem0.embeddings.base import EmbeddingBase-class VertexAI(EmbeddingBase):+class VertexAIEmbedding(EmbeddingBase):def __init__(self, config: Optional[BaseEmbedderConfig] = None):super().__init__(config)diff --git a/mem0/utils/factory.py b/mem0/utils/factory.pyindex 034fc6fc5..43f853c68 100644--- a/mem0/utils/factory.py+++ b/mem0/utils/factory.py@@ -42,6 +42,7 @@ class EmbedderFactory:"huggingface": "mem0.embeddings.huggingface.HuggingFaceEmbedding","azure_openai": "mem0.embeddings.azure_openai.AzureOpenAIEmbedding","gemini": "mem0.embeddings.gemini.GoogleGenAIEmbedding",+ "vertexai": "mem0.embeddings.vertexai.VertexAIEmbedding",}@classmethoddiff --git a/tests/embeddings/test_vertexai_embeddings.py b/tests/embeddings/test_vertexai_embeddings.pyindex 4b85e077e..26ac63414 100644--- a/tests/embeddings/test_vertexai_embeddings.py+++ b/tests/embeddings/test_vertexai_embeddings.py@@ -1,6 +1,6 @@import pytestfrom unittest.mock import Mock, patch-from mem0.embeddings.vertexai import VertexAI+from mem0.embeddings.vertexai import VertexAIEmbeddingfrom mem0.configs.embeddings.base import BaseEmbedderConfig@@ -32,7 +32,7 @@ def test_embed_default_model(mock_text_embedding_model, mock_os_environ, mock_comock_config.return_value.embedding_dims = 256config = mock_config()- embedder = VertexAI(config)+ embedder = VertexAIEmbedding(config)mock_embedding = Mock(values=[0.1, 0.2, 0.3])mock_text_embedding_model.from_pretrained.return_value.get_embeddings.return_value = [@@ -57,7 +57,7 @@ def test_embed_custom_model(mock_text_embedding_model, mock_os_environ, mock_conconfig = mock_config()- embedder = VertexAI(config)+ embedder = VertexAIEmbedding(config)mock_embedding = Mock(values=[0.4, 0.5, 0.6])mock_text_embedding_model.from_pretrained.return_value.get_embeddings.return_value = [@@ -81,7 +81,7 @@ def test_credentials_from_environment(mock_os, mock_text_embedding_model, mock_cmock_os.getenv.return_value = "/path/to/env/credentials.json"mock_config.vertex_credentials_json = Noneconfig = mock_config()- VertexAI(config)+ VertexAIEmbedding(config)mock_os.environ.setitem.assert_not_called()@@ -96,7 +96,7 @@ def test_missing_credentials(mock_os, mock_text_embedding_model, mock_config):with pytest.raises(ValueError, match="Google application credentials JSON is not provided"):- VertexAI(config)+ VertexAIEmbedding(config)@patch("mem0.embeddings.vertexai.TextEmbeddingModel")@@ -107,7 +107,7 @@ def test_embed_with_different_dimensions(mock_config.return_value.embedding_dims = 1024config = mock_config()- embedder = VertexAI(config)+ embedder = VertexAIEmbedding(config)mock_embedding = Mock(values=[0.1] * 1024)mock_text_embedding_model.from_pretrained.return_value.get_embeddings.return_value = [