mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
fix: use mem0_local_config instead of config in Memory.from_config (#2587)
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -48,7 +48,7 @@ class Mem0Storage(Storage):
|
||||
self.memory = MemoryClient(api_key=mem0_api_key)
|
||||
else:
|
||||
if mem0_local_config and len(mem0_local_config):
|
||||
self.memory = Memory.from_config(config)
|
||||
self.memory = Memory.from_config(mem0_local_config)
|
||||
else:
|
||||
self.memory = Memory()
|
||||
|
||||
|
||||
@@ -153,3 +153,31 @@ def test_mem0_storage_with_explict_config(
|
||||
mem0_storage_with_memory_client_using_explictly_config.memory_config
|
||||
== expected_config
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def mem0_storage_with_local_config(mock_mem0_memory):
|
||||
"""Fixture to create a Mem0Storage instance with local mem0 config"""
|
||||
|
||||
# Patch the Memory class to return our mock
|
||||
with patch("mem0.memory.main.Memory.from_config", return_value=mock_mem0_memory) as mock_from_config:
|
||||
local_config = {
|
||||
"vector_store": {"provider": "mock_vector_store"},
|
||||
"llm": {"provider": "mock_llm"},
|
||||
"embedder": {"provider": "mock_embedder"},
|
||||
}
|
||||
|
||||
crew = MockCrew(
|
||||
memory_config={
|
||||
"provider": "mem0",
|
||||
"config": {"user_id": "test_user", "local_mem0_config": local_config},
|
||||
}
|
||||
)
|
||||
|
||||
mem0_storage = Mem0Storage(type="short_term", crew=crew)
|
||||
return mem0_storage, mock_from_config, local_config
|
||||
|
||||
|
||||
def test_mem0_storage_uses_local_config(mem0_storage_with_local_config):
|
||||
"""Test that Mem0Storage correctly uses local_mem0_config when initializing Memory"""
|
||||
_, mock_from_config, local_config = mem0_storage_with_local_config
|
||||
mock_from_config.assert_called_once_with(local_config)
|
||||
|
||||
Reference in New Issue
Block a user