@@ -117,7 +117,7 @@ public function testCacheStoreWithCustomKeyCanBeConfigured()
117
117
'cache ' => [
118
118
'my_cache_store_with_custom_strategy ' => [
119
119
'service ' => 'cache.system ' ,
120
- 'key ' => 'random ' ,
120
+ 'cache_key ' => 'random ' ,
121
121
],
122
122
],
123
123
],
@@ -129,7 +129,7 @@ public function testCacheStoreWithCustomKeyCanBeConfigured()
129
129
130
130
$ definition = $ container ->getDefinition ('ai.store.cache.my_cache_store_with_custom_strategy ' );
131
131
132
- $ this ->assertCount (2 , $ definition ->getArguments ());
132
+ $ this ->assertCount (3 , $ definition ->getArguments ());
133
133
$ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
134
134
$ this ->assertSame ('cache.system ' , (string ) $ definition ->getArgument (0 ));
135
135
$ this ->assertSame ('random ' , $ definition ->getArgument (2 ));
@@ -155,10 +155,9 @@ public function testCacheStoreWithCustomStrategyCanBeConfigured()
155
155
156
156
$ definition = $ container ->getDefinition ('ai.store.cache.my_cache_store_with_custom_strategy ' );
157
157
158
- $ this ->assertCount (3 , $ definition ->getArguments ());
158
+ $ this ->assertCount (2 , $ definition ->getArguments ());
159
159
$ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
160
160
$ this ->assertSame ('cache.system ' , (string ) $ definition ->getArgument (0 ));
161
- $ this ->assertSame ('_vectors ' , $ definition ->getArgument (2 ));
162
161
$ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (1 ));
163
162
$ this ->assertSame ('ai.store.distance_calculator.my_cache_store_with_custom_strategy ' , (string ) $ definition ->getArgument (1 ));
164
163
}
@@ -171,7 +170,7 @@ public function testCacheStoreWithCustomStrategyAndKeyCanBeConfigured()
171
170
'cache ' => [
172
171
'my_cache_store_with_custom_strategy ' => [
173
172
'service ' => 'cache.system ' ,
174
- 'key ' => 'random ' ,
173
+ 'cache_key ' => 'random ' ,
175
174
'strategy ' => 'chebyshev ' ,
176
175
],
177
176
],
@@ -192,6 +191,48 @@ public function testCacheStoreWithCustomStrategyAndKeyCanBeConfigured()
192
191
$ this ->assertSame ('ai.store.distance_calculator.my_cache_store_with_custom_strategy ' , (string ) $ definition ->getArgument (1 ));
193
192
}
194
193
194
+ public function testInMemoryStoreWithoutCustomStrategyCanBeConfigured ()
195
+ {
196
+ $ container = $ this ->buildContainer ([
197
+ 'ai ' => [
198
+ 'store ' => [
199
+ 'memory ' => [
200
+ 'my_memory_store_with_custom_strategy ' => [],
201
+ ],
202
+ ],
203
+ ],
204
+ ]);
205
+
206
+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.memory.my_memory_store_with_custom_strategy ' ));
207
+
208
+ $ definition = $ container ->getDefinition ('ai.store.memory.my_memory_store_with_custom_strategy ' );
209
+ $ this ->assertCount (0 , $ definition ->getArguments ());
210
+ }
211
+
212
+ public function testInMemoryStoreWithCustomStrategyCanBeConfigured ()
213
+ {
214
+ $ container = $ this ->buildContainer ([
215
+ 'ai ' => [
216
+ 'store ' => [
217
+ 'memory ' => [
218
+ 'my_memory_store_with_custom_strategy ' => [
219
+ 'strategy ' => 'chebyshev ' ,
220
+ ],
221
+ ],
222
+ ],
223
+ ],
224
+ ]);
225
+
226
+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.memory.my_memory_store_with_custom_strategy ' ));
227
+ $ this ->assertTrue ($ container ->hasDefinition ('ai.store.distance_calculator.my_memory_store_with_custom_strategy ' ));
228
+
229
+ $ definition = $ container ->getDefinition ('ai.store.memory.my_memory_store_with_custom_strategy ' );
230
+
231
+ $ this ->assertCount (1 , $ definition ->getArguments ());
232
+ $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
233
+ $ this ->assertSame ('ai.store.distance_calculator.my_memory_store_with_custom_strategy ' , (string ) $ definition ->getArgument (0 ));
234
+ }
235
+
195
236
private function buildContainer (array $ configuration ): ContainerBuilder
196
237
{
197
238
$ container = new ContainerBuilder ();
@@ -294,12 +335,17 @@ private function getFullConfig(): array
294
335
],
295
336
'my_cache_store_with_custom_key ' => [
296
337
'service ' => 'cache.system ' ,
297
- 'key ' => 'bar ' ,
338
+ 'cache_key ' => 'bar ' ,
298
339
],
299
340
'my_cache_store_with_custom_strategy ' => [
300
341
'service ' => 'cache.system ' ,
301
342
'strategy ' => 'chebyshev ' ,
302
343
],
344
+ 'my_cache_store_with_custom_strategy_and_custom_key ' => [
345
+ 'service ' => 'cache.system ' ,
346
+ 'cache_key ' => 'bar ' ,
347
+ 'strategy ' => 'chebyshev ' ,
348
+ ],
303
349
],
304
350
'chroma_db ' => [
305
351
'my_chroma_store ' => [
@@ -325,7 +371,7 @@ private function getFullConfig(): array
325
371
],
326
372
'memory ' => [
327
373
'my_memory_store ' => [
328
- 'distance ' => 'cosine ' ,
374
+ 'strategy ' => 'cosine ' ,
329
375
],
330
376
],
331
377
'mongodb ' => [
0 commit comments