Skip to content

Commit a37335a

Browse files
committed
Enhance MemoryAgent tests with updated embedding engine configuration
This commit modifies the `test_memory_agent.py` file to incorporate the new `text_model_name` configuration in the `MemoryConfig`. The tests are updated to reflect changes in the embedding engine initialization, ensuring proper assertions for the new configuration options. Additionally, the mock patches are adjusted to use the correct embedding engine class.
1 parent 16548e3 commit a37335a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/test_memory_agent.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def memory_agent(
9898
agent_id = "test-agent"
9999
config = MemoryConfig()
100100
config.autoencoder_config.use_neural_embeddings = True
101+
config.text_model_name = "test-model"
101102
config.ltm_config.db_path = "test_memory.db" # Set a valid db path
102103

103104
# Mock store classes before instantiating the agent
@@ -108,7 +109,7 @@ def memory_agent(
108109
) as mock_ltm_class, mock.patch(
109110
"memory.agent_memory.CompressionEngine"
110111
), mock.patch(
111-
"memory.agent_memory.AutoencoderEmbeddingEngine"
112+
"memory.embeddings.text_embeddings.TextEmbeddingEngine"
112113
):
113114

114115
# Configure the mock classes to return our mock instances
@@ -133,7 +134,10 @@ def test_init(self):
133134
"""Test memory agent initialization."""
134135
agent_id = "test-agent"
135136
config = MemoryConfig()
136-
config.autoencoder_config.use_neural_embeddings = True
137+
config.use_embedding_engine = True
138+
config.text_model_name = (
139+
"sentence-transformers/all-MiniLM-L6-v2" # Use a real model
140+
)
137141
config.ltm_config.db_path = "test_memory.db" # Set a valid db path
138142

139143
with mock.patch("memory.agent_memory.RedisSTMStore") as mock_stm, mock.patch(
@@ -143,7 +147,7 @@ def test_init(self):
143147
) as mock_ltm, mock.patch(
144148
"memory.agent_memory.CompressionEngine"
145149
) as mock_ce, mock.patch(
146-
"memory.agent_memory.AutoencoderEmbeddingEngine"
150+
"memory.embeddings.text_embeddings.TextEmbeddingEngine"
147151
) as mock_ae:
148152

149153
agent = MemoryAgent(agent_id, config)
@@ -153,7 +157,7 @@ def test_init(self):
153157
mock_im.assert_called_once_with(config.im_config)
154158
mock_ltm.assert_called_once_with(agent_id, config.ltm_config)
155159
mock_ce.assert_called_once_with(config.autoencoder_config)
156-
mock_ae.assert_called_once()
160+
mock_ae.assert_called_once_with(model_name=config.text_model_name)
157161

158162
assert agent.agent_id == agent_id
159163
assert agent.config == config
@@ -162,17 +166,20 @@ def test_init_without_neural_embeddings(self):
162166
"""Test memory agent initialization without neural embeddings."""
163167
agent_id = "test-agent"
164168
config = MemoryConfig()
165-
config.autoencoder_config.use_neural_embeddings = False
169+
config.use_embedding_engine = False
166170
config.ltm_config.db_path = "test_memory.db" # Set a valid db path
167171

168172
with mock.patch("memory.agent_memory.RedisSTMStore"), mock.patch(
169173
"memory.agent_memory.RedisIMStore"
170174
), mock.patch("memory.agent_memory.SQLiteLTMStore"), mock.patch(
171175
"memory.agent_memory.CompressionEngine"
172-
):
176+
), mock.patch(
177+
"memory.embeddings.text_embeddings.TextEmbeddingEngine"
178+
) as mock_te:
173179

174180
agent = MemoryAgent(agent_id, config)
175181
assert agent.embedding_engine is None
182+
mock_te.assert_not_called()
176183

177184

178185
class TestMemoryStorage:

0 commit comments

Comments
 (0)