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
Validate embedding_dims in kuzu, fix #3556 (#3558)
Alex Kondratevce8a285003a8
diff --git a/mem0/memory/kuzu_memory.py b/mem0/memory/kuzu_memory.pyindex 828e2e174..021fb2fe7 100644--- a/mem0/memory/kuzu_memory.py+++ b/mem0/memory/kuzu_memory.py@@ -37,6 +37,9 @@ class MemoryGraph:)self.embedding_dims = self.embedding_model.config.embedding_dims+ if self.embedding_dims is None or self.embedding_dims <= 0:+ raise ValueError(f"embedding_dims must be a positive integer. Given: {self.embedding_dims}")+self.db = kuzu.Database(self.config.graph_store.config.db)self.graph = kuzu.Connection(self.db)diff --git a/tests/memory/test_kuzu.py b/tests/memory/test_kuzu.pyindex 334912add..38a1a9ea0 100644--- a/tests/memory/test_kuzu.py+++ b/tests/memory/test_kuzu.py@@ -79,6 +79,22 @@ class TestKuzu:assert kuzu_memory.llm == mock_llmassert kuzu_memory.threshold == 0.7+ @pytest.mark.parametrize(+ "embedding_dims",+ [None, 0, -1],+ )+ @patch("mem0.memory.kuzu_memory.EmbedderFactory")+ def test_kuzu_memory_initialization_invalid_embedding_dims(+ self, mock_embedder_factory, embedding_dims, mock_config+ ):+ """Test that Kuzu memory raises ValuError when initialized with invalid embedding_dims"""+ # Setup mocks+ mock_embedding_model = Mock()+ mock_embedding_model.config.embedding_dims = embedding_dims+ mock_embedder_factory.create.return_value = mock_embedding_model++ with pytest.raises(ValueError, match="must be a positive"):+ MemoryGraph(mock_config)@patch("mem0.memory.kuzu_memory.EmbedderFactory")@patch("mem0.memory.kuzu_memory.LlmFactory")