2727use Symfony \AI \Store \Document \Transformer \TextTrimTransformer ;
2828use Symfony \AI \Store \Document \Vectorizer ;
2929use Symfony \AI \Store \StoreInterface ;
30+ use Symfony \Component \Clock \ClockInterface ;
3031use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
3132use Symfony \Component \DependencyInjection \ContainerBuilder ;
3233use Symfony \Component \DependencyInjection \ContainerInterface ;
@@ -387,11 +388,12 @@ public function testCacheStoreWithCustomStrategyCanBeConfigured()
387388
388389 $ definition = $ container ->getDefinition ('ai.store.cache.my_cache_store_with_custom_strategy ' );
389390
390- $ this ->assertCount (2 , $ definition ->getArguments ());
391+ $ this ->assertCount (3 , $ definition ->getArguments ());
391392 $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
392393 $ this ->assertSame ('cache.system ' , (string ) $ definition ->getArgument (0 ));
393394 $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (1 ));
394395 $ this ->assertSame ('ai.store.distance_calculator.my_cache_store_with_custom_strategy ' , (string ) $ definition ->getArgument (1 ));
396+ $ this ->assertSame ('my_cache_store_with_custom_strategy ' , $ definition ->getArgument (2 ));
395397 }
396398
397399 public function testCacheStoreWithCustomStrategyAndKeyCanBeConfigured ()
@@ -418,9 +420,9 @@ public function testCacheStoreWithCustomStrategyAndKeyCanBeConfigured()
418420 $ this ->assertCount (3 , $ definition ->getArguments ());
419421 $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (0 ));
420422 $ this ->assertSame ('cache.system ' , (string ) $ definition ->getArgument (0 ));
421- $ this ->assertSame ('random ' , $ definition ->getArgument (2 ));
422423 $ this ->assertInstanceOf (Reference::class, $ definition ->getArgument (1 ));
423424 $ this ->assertSame ('ai.store.distance_calculator.my_cache_store_with_custom_strategy ' , (string ) $ definition ->getArgument (1 ));
425+ $ this ->assertSame ('random ' , $ definition ->getArgument (2 ));
424426 }
425427
426428 public function testInMemoryStoreWithoutCustomStrategyCanBeConfigured ()
@@ -2778,6 +2780,10 @@ public function testCacheMessageStoreCanBeConfiguredWithCustomKey()
27782780 $ this ->assertSame ('cache.app ' , (string ) $ cacheMessageStoreDefinition ->getArgument (0 ));
27792781
27802782 $ this ->assertSame ('custom ' , (string ) $ cacheMessageStoreDefinition ->getArgument (1 ));
2783+
2784+ $ this ->assertTrue ($ cacheMessageStoreDefinition ->hasTag ('proxy ' ));
2785+ $ this ->assertSame ([['interface ' => MessageStoreInterface::class]], $ cacheMessageStoreDefinition ->getTag ('proxy ' ));
2786+ $ this ->assertTrue ($ cacheMessageStoreDefinition ->hasTag ('ai.message_store ' ));
27812787 }
27822788
27832789 public function testCacheMessageStoreCanBeConfiguredWithCustomTtl ()
@@ -2797,11 +2803,70 @@ public function testCacheMessageStoreCanBeConfiguredWithCustomTtl()
27972803
27982804 $ cacheMessageStoreDefinition = $ container ->getDefinition ('ai.message_store.cache.custom ' );
27992805
2806+ $ this ->assertTrue ($ cacheMessageStoreDefinition ->isLazy ());
28002807 $ this ->assertInstanceOf (Reference::class, $ cacheMessageStoreDefinition ->getArgument (0 ));
28012808 $ this ->assertSame ('cache.app ' , (string ) $ cacheMessageStoreDefinition ->getArgument (0 ));
28022809
28032810 $ this ->assertSame ('custom ' , (string ) $ cacheMessageStoreDefinition ->getArgument (1 ));
28042811 $ this ->assertSame (3600 , (int ) $ cacheMessageStoreDefinition ->getArgument (2 ));
2812+
2813+ $ this ->assertTrue ($ cacheMessageStoreDefinition ->hasTag ('proxy ' ));
2814+ $ this ->assertSame ([['interface ' => MessageStoreInterface::class]], $ cacheMessageStoreDefinition ->getTag ('proxy ' ));
2815+ $ this ->assertTrue ($ cacheMessageStoreDefinition ->hasTag ('ai.message_store ' ));
2816+ }
2817+
2818+ public function testMemoryMessageStoreCanBeConfiguredWithCustomKey ()
2819+ {
2820+ $ container = $ this ->buildContainer ([
2821+ 'ai ' => [
2822+ 'message_store ' => [
2823+ 'memory ' => [
2824+ 'custom ' => [
2825+ 'identifier ' => 'foo ' ,
2826+ ],
2827+ ],
2828+ ],
2829+ ],
2830+ ]);
2831+
2832+ $ memoryMessageStoreDefinition = $ container ->getDefinition ('ai.message_store.memory.custom ' );
2833+
2834+ $ this ->assertTrue ($ memoryMessageStoreDefinition ->isLazy ());
2835+ $ this ->assertSame ('foo ' , $ memoryMessageStoreDefinition ->getArgument (0 ));
2836+
2837+ $ this ->assertTrue ($ memoryMessageStoreDefinition ->hasTag ('proxy ' ));
2838+ $ this ->assertSame ([['interface ' => MessageStoreInterface::class]], $ memoryMessageStoreDefinition ->getTag ('proxy ' ));
2839+ $ this ->assertTrue ($ memoryMessageStoreDefinition ->hasTag ('ai.message_store ' ));
2840+ }
2841+
2842+ public function testMeilisearchMessageStoreIsConfigured ()
2843+ {
2844+ $ container = $ this ->buildContainer ([
2845+ 'ai ' => [
2846+ 'message_store ' => [
2847+ 'meilisearch ' => [
2848+ 'custom ' => [
2849+ 'endpoint ' => 'http://127.0.0.1:7700 ' ,
2850+ 'api_key ' => 'foo ' ,
2851+ 'index_name ' => 'test ' ,
2852+ ],
2853+ ],
2854+ ],
2855+ ],
2856+ ]);
2857+
2858+ $ meilisearchMessageStoreDefinition = $ container ->getDefinition ('ai.message_store.meilisearch.custom ' );
2859+
2860+ $ this ->assertTrue ($ meilisearchMessageStoreDefinition ->isLazy ());
2861+ $ this ->assertSame ('http://127.0.0.1:7700 ' , $ meilisearchMessageStoreDefinition ->getArgument (0 ));
2862+ $ this ->assertSame ('foo ' , $ meilisearchMessageStoreDefinition ->getArgument (1 ));
2863+ $ this ->assertInstanceOf (Reference::class, $ meilisearchMessageStoreDefinition ->getArgument (2 ));
2864+ $ this ->assertSame (ClockInterface::class, (string ) $ meilisearchMessageStoreDefinition ->getArgument (2 ));
2865+ $ this ->assertSame ('test ' , $ meilisearchMessageStoreDefinition ->getArgument (3 ));
2866+
2867+ $ this ->assertTrue ($ meilisearchMessageStoreDefinition ->hasTag ('proxy ' ));
2868+ $ this ->assertSame ([['interface ' => MessageStoreInterface::class]], $ meilisearchMessageStoreDefinition ->getTag ('proxy ' ));
2869+ $ this ->assertTrue ($ meilisearchMessageStoreDefinition ->hasTag ('ai.message_store ' ));
28052870 }
28062871
28072872 private function buildContainer (array $ configuration ): ContainerBuilder
0 commit comments