2121use Symfony \AI \Agent \MultiAgent \Handoff ;
2222use Symfony \AI \Agent \MultiAgent \MultiAgent ;
2323use Symfony \AI \AiBundle \AiBundle ;
24+ use Symfony \AI \Chat \MessageStoreInterface ;
2425use Symfony \AI \Store \Document \Filter \TextContainsFilter ;
2526use Symfony \AI \Store \Document \Loader \InMemoryLoader ;
2627use Symfony \AI \Store \Document \Transformer \TextTrimTransformer ;
@@ -58,6 +59,30 @@ public function testStoreCommandsArentDefinedWithoutStore()
5859 $ this ->assertSame ([
5960 'ai.command.setup_store ' => true ,
6061 'ai.command.drop_store ' => true ,
62+ 'ai.command.setup_message_store ' => true ,
63+ 'ai.command.drop_message_store ' => true ,
64+ ], $ container ->getRemovedIds ());
65+ }
66+
67+ public function testMessageStoreCommandsArentDefinedWithoutMessageStore ()
68+ {
69+ $ container = $ this ->buildContainer ([
70+ 'ai ' => [
71+ 'agent ' => [
72+ 'my_agent ' => [
73+ 'model ' => 'gpt-4 ' ,
74+ ],
75+ ],
76+ ],
77+ ]);
78+
79+ $ this ->assertFalse ($ container ->hasDefinition ('ai.command.setup_message_store ' ));
80+ $ this ->assertFalse ($ container ->hasDefinition ('ai.command.drop_message_store ' ));
81+ $ this ->assertSame ([
82+ 'ai.command.setup_store ' => true ,
83+ 'ai.command.drop_store ' => true ,
84+ 'ai.command.setup_message_store ' => true ,
85+ 'ai.command.drop_message_store ' => true ,
6186 ], $ container ->getRemovedIds ());
6287 }
6388
@@ -78,6 +103,23 @@ public function testStoreCommandsAreDefined()
78103 $ this ->assertArrayHasKey ('console.command ' , $ dropStoreCommandDefinition ->getTags ());
79104 }
80105
106+ public function testMessageStoreCommandsAreDefined ()
107+ {
108+ $ container = $ this ->buildContainer ($ this ->getFullConfig ());
109+
110+ $ this ->assertTrue ($ container ->hasDefinition ('ai.command.setup_message_store ' ));
111+
112+ $ setupStoreCommandDefinition = $ container ->getDefinition ('ai.command.setup_message_store ' );
113+ $ this ->assertCount (1 , $ setupStoreCommandDefinition ->getArguments ());
114+ $ this ->assertArrayHasKey ('console.command ' , $ setupStoreCommandDefinition ->getTags ());
115+
116+ $ this ->assertTrue ($ container ->hasDefinition ('ai.command.drop_message_store ' ));
117+
118+ $ dropStoreCommandDefinition = $ container ->getDefinition ('ai.command.drop_message_store ' );
119+ $ this ->assertCount (1 , $ dropStoreCommandDefinition ->getArguments ());
120+ $ this ->assertArrayHasKey ('console.command ' , $ dropStoreCommandDefinition ->getTags ());
121+ }
122+
81123 public function testInjectionAgentAliasIsRegistered ()
82124 {
83125 $ container = $ this ->buildContainer ([
@@ -125,6 +167,31 @@ public function testInjectionStoreAliasIsRegistered()
125167 $ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $weaviateMain ' ));
126168 }
127169
170+ public function testInjectionMessageStoreAliasIsRegistered ()
171+ {
172+ $ container = $ this ->buildContainer ([
173+ 'ai ' => [
174+ 'message_store ' => [
175+ 'memory ' => [
176+ 'main ' => [
177+ 'identifier ' => '_memory ' ,
178+ ],
179+ ],
180+ 'session ' => [
181+ 'session ' => [
182+ 'identifier ' => 'session ' ,
183+ ],
184+ ],
185+ ],
186+ ],
187+ ]);
188+
189+ $ this ->assertTrue ($ container ->hasAlias (MessageStoreInterface::class.' $main ' ));
190+ $ this ->assertTrue ($ container ->hasAlias ('. ' .MessageStoreInterface::class.' $memory_main ' ));
191+ $ this ->assertTrue ($ container ->hasAlias (MessageStoreInterface::class.' $session ' ));
192+ $ this ->assertTrue ($ container ->hasAlias ('. ' .MessageStoreInterface::class.' $session_session ' ));
193+ }
194+
128195 public function testAgentHasTag ()
129196 {
130197 $ container = $ this ->buildContainer ([
@@ -2943,6 +3010,27 @@ private function getFullConfig(): array
29433010 ],
29443011 ],
29453012 ],
3013+ 'message_store ' => [
3014+ 'cache ' => [
3015+ 'my_cache_message_store ' => [
3016+ 'service ' => 'cache.system ' ,
3017+ ],
3018+ 'my_cache_message_store_with_custom_cache_key ' => [
3019+ 'service ' => 'cache.system ' ,
3020+ 'key ' => 'foo ' ,
3021+ ],
3022+ ],
3023+ 'memory ' => [
3024+ 'my_memory_message_store ' => [
3025+ 'identifier ' => '_memory ' ,
3026+ ],
3027+ ],
3028+ 'session ' => [
3029+ 'my_session_message_store ' => [
3030+ 'identifier ' => 'session ' ,
3031+ ],
3032+ ],
3033+ ],
29463034 'vectorizer ' => [
29473035 'test_vectorizer ' => [
29483036 'platform ' => 'mistral_platform_service_id ' ,
0 commit comments