21
21
use Symfony \AI \Agent \MultiAgent \Handoff ;
22
22
use Symfony \AI \Agent \MultiAgent \MultiAgent ;
23
23
use Symfony \AI \AiBundle \AiBundle ;
24
+ use Symfony \AI \Chat \MessageStoreInterface ;
24
25
use Symfony \AI \Store \Document \Filter \TextContainsFilter ;
25
26
use Symfony \AI \Store \Document \Loader \InMemoryLoader ;
26
27
use Symfony \AI \Store \Document \Transformer \TextTrimTransformer ;
@@ -58,6 +59,30 @@ public function testStoreCommandsArentDefinedWithoutStore()
58
59
$ this ->assertSame ([
59
60
'ai.command.setup_store ' => true ,
60
61
'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 ,
61
86
], $ container ->getRemovedIds ());
62
87
}
63
88
@@ -78,6 +103,23 @@ public function testStoreCommandsAreDefined()
78
103
$ this ->assertArrayHasKey ('console.command ' , $ dropStoreCommandDefinition ->getTags ());
79
104
}
80
105
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
+
81
123
public function testInjectionAgentAliasIsRegistered ()
82
124
{
83
125
$ container = $ this ->buildContainer ([
@@ -125,6 +167,31 @@ public function testInjectionStoreAliasIsRegistered()
125
167
$ this ->assertTrue ($ container ->hasAlias (StoreInterface::class.' $weaviateMain ' ));
126
168
}
127
169
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
+
128
195
public function testAgentHasTag ()
129
196
{
130
197
$ container = $ this ->buildContainer ([
@@ -2895,6 +2962,27 @@ private function getFullConfig(): array
2895
2962
],
2896
2963
],
2897
2964
],
2965
+ 'message_store ' => [
2966
+ 'cache ' => [
2967
+ 'my_cache_message_store ' => [
2968
+ 'service ' => 'cache.system ' ,
2969
+ ],
2970
+ 'my_cache_message_store_with_custom_cache_key ' => [
2971
+ 'service ' => 'cache.system ' ,
2972
+ 'key ' => 'foo ' ,
2973
+ ],
2974
+ ],
2975
+ 'memory ' => [
2976
+ 'my_memory_message_store ' => [
2977
+ 'identifier ' => '_memory ' ,
2978
+ ],
2979
+ ],
2980
+ 'session ' => [
2981
+ 'my_session_message_store ' => [
2982
+ 'identifier ' => 'session ' ,
2983
+ ],
2984
+ ],
2985
+ ],
2898
2986
'vectorizer ' => [
2899
2987
'test_vectorizer ' => [
2900
2988
'platform ' => 'mistral_platform_service_id ' ,
0 commit comments