16
16
use Symfony \AI \Agent \InputProcessor \SystemPromptInputProcessor ;
17
17
use Symfony \AI \Agent \InputProcessorInterface ;
18
18
use Symfony \AI \Agent \OutputProcessorInterface ;
19
- use Symfony \AI \Agent \StructuredOutput \AgentProcessor as StructureOutputProcessor ;
20
19
use Symfony \AI \Agent \Toolbox \AgentProcessor as ToolProcessor ;
21
20
use Symfony \AI \Agent \Toolbox \Attribute \AsTool ;
22
21
use Symfony \AI \Agent \Toolbox \FaultTolerantToolbox ;
23
22
use Symfony \AI \Agent \Toolbox \Tool \Agent as AgentTool ;
24
23
use Symfony \AI \Agent \Toolbox \ToolFactory \ChainFactory ;
25
24
use Symfony \AI \Agent \Toolbox \ToolFactory \MemoryToolFactory ;
26
- use Symfony \AI \Agent \Toolbox \ToolFactory \ReflectionToolFactory ;
27
25
use Symfony \AI \AIBundle \Exception \InvalidArgumentException ;
28
26
use Symfony \AI \AIBundle \Profiler \DataCollector ;
29
27
use Symfony \AI \AIBundle \Profiler \TraceablePlatform ;
52
50
use Symfony \Component \Config \Definition \Configurator \DefinitionConfigurator ;
53
51
use Symfony \Component \DependencyInjection \ChildDefinition ;
54
52
use Symfony \Component \DependencyInjection \ContainerBuilder ;
53
+ use Symfony \Component \DependencyInjection \ContainerInterface ;
55
54
use Symfony \Component \DependencyInjection \Definition ;
56
55
use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
57
56
use Symfony \Component \DependencyInjection \Reference ;
@@ -158,11 +157,12 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
158
157
$ platformId = 'ai.platform.anthropic ' ;
159
158
$ definition = (new Definition (Platform::class))
160
159
->setFactory (AnthropicPlatformFactory::class.'::create ' )
161
- ->setAutowired (true )
162
160
->setLazy (true )
163
161
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
164
162
->setArguments ([
165
163
'$apiKey ' => $ platform ['api_key ' ],
164
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
165
+ '$contract ' => new Reference ('ai.platform.contract ' ),
166
166
])
167
167
->addTag ('ai.platform ' );
168
168
@@ -180,14 +180,15 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
180
180
$ platformId = 'ai.platform.azure. ' .$ name ;
181
181
$ definition = (new Definition (Platform::class))
182
182
->setFactory (AzureOpenAIPlatformFactory::class.'::create ' )
183
- ->setAutowired (true )
184
183
->setLazy (true )
185
184
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
186
185
->setArguments ([
187
186
'$baseUrl ' => $ config ['base_url ' ],
188
187
'$deployment ' => $ config ['deployment ' ],
189
188
'$apiVersion ' => $ config ['api_version ' ],
190
189
'$apiKey ' => $ config ['api_key ' ],
190
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
191
+ '$contract ' => new Reference ('ai.platform.contract ' ),
191
192
])
192
193
->addTag ('ai.platform ' );
193
194
@@ -201,10 +202,13 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
201
202
$ platformId = 'ai.platform.google ' ;
202
203
$ definition = (new Definition (Platform::class))
203
204
->setFactory (GooglePlatformFactory::class.'::create ' )
204
- ->setAutowired (true )
205
205
->setLazy (true )
206
206
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
207
- ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
207
+ ->setArguments ([
208
+ '$apiKey ' => $ platform ['api_key ' ],
209
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
210
+ '$contract ' => new Reference ('ai.platform.contract ' ),
211
+ ])
208
212
->addTag ('ai.platform ' );
209
213
210
214
$ container ->setDefinition ($ platformId , $ definition );
@@ -216,10 +220,13 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
216
220
$ platformId = 'ai.platform.openai ' ;
217
221
$ definition = (new Definition (Platform::class))
218
222
->setFactory (OpenAIPlatformFactory::class.'::create ' )
219
- ->setAutowired (true )
220
223
->setLazy (true )
221
224
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
222
- ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
225
+ ->setArguments ([
226
+ '$apiKey ' => $ platform ['api_key ' ],
227
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
228
+ '$contract ' => new Reference ('ai.platform.contract ' ),
229
+ ])
223
230
->addTag ('ai.platform ' );
224
231
225
232
$ container ->setDefinition ($ platformId , $ definition );
@@ -231,10 +238,13 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
231
238
$ platformId = 'ai.platform.openrouter ' ;
232
239
$ definition = (new Definition (Platform::class))
233
240
->setFactory (OpenRouterPlatformFactory::class.'::create ' )
234
- ->setAutowired (true )
235
241
->setLazy (true )
236
242
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
237
- ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
243
+ ->setArguments ([
244
+ '$apiKey ' => $ platform ['api_key ' ],
245
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
246
+ '$contract ' => new Reference ('ai.platform.contract ' ),
247
+ ])
238
248
->addTag ('ai.platform ' );
239
249
240
250
$ container ->setDefinition ($ platformId , $ definition );
@@ -246,10 +256,13 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
246
256
$ platformId = 'ai.platform.mistral ' ;
247
257
$ definition = (new Definition (Platform::class))
248
258
->setFactory (MistralPlatformFactory::class.'::create ' )
249
- ->setAutowired (true )
250
259
->setLazy (true )
251
260
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
252
- ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
261
+ ->setArguments ([
262
+ '$apiKey ' => $ platform ['api_key ' ],
263
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
264
+ '$contract ' => new Reference ('ai.platform.contract ' ),
265
+ ])
253
266
->addTag ('ai.platform ' );
254
267
255
268
$ container ->setDefinition ($ platformId , $ definition );
@@ -261,10 +274,13 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
261
274
$ platformId = 'symfony_ai.platform.lmstudio ' ;
262
275
$ definition = (new Definition (Platform::class))
263
276
->setFactory (LMStudioPlatformFactory::class.'::create ' )
264
- ->setAutowired (true )
265
277
->setLazy (true )
266
278
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
267
- ->setArguments (['$hostUrl ' => $ platform ['host_url ' ]])
279
+ ->setArguments ([
280
+ '$hostUrl ' => $ platform ['host_url ' ],
281
+ '$httpClient ' => new Reference ('http_client ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
282
+ '$contract ' => new Reference ('ai.platform.contract ' ),
283
+ ])
268
284
->addTag ('symfony_ai.platform ' );
269
285
270
286
$ container ->setDefinition ($ platformId , $ definition );
@@ -299,7 +315,6 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
299
315
300
316
// AGENT
301
317
$ agentDefinition = (new Definition (Agent::class))
302
- ->setAutowired (true )
303
318
->setArgument ('$platform ' , new Reference ($ config ['platform ' ]))
304
319
->setArgument ('$model ' , new Reference ('ai.agent. ' .$ name .'.model ' ));
305
320
@@ -313,7 +328,7 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
313
328
$ memoryFactoryDefinition = new Definition (MemoryToolFactory::class);
314
329
$ container ->setDefinition ('ai.toolbox. ' .$ name .'.memory_factory ' , $ memoryFactoryDefinition );
315
330
$ chainFactoryDefinition = new Definition (ChainFactory::class, [
316
- '$factories ' => [new Reference ('ai.toolbox. ' .$ name .'.memory_factory ' ), new Reference (ReflectionToolFactory::class )],
331
+ '$factories ' => [new Reference ('ai.toolbox. ' .$ name .'.memory_factory ' ), new Reference (' ai.tool_factory ' )],
317
332
]);
318
333
$ container ->setDefinition ('ai.toolbox. ' .$ name .'.chain_factory ' , $ chainFactoryDefinition );
319
334
@@ -368,8 +383,8 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
368
383
369
384
// STRUCTURED OUTPUT
370
385
if ($ config ['structured_output ' ]) {
371
- $ inputProcessors [] = new Reference (StructureOutputProcessor::class );
372
- $ outputProcessors [] = new Reference (StructureOutputProcessor::class );
386
+ $ inputProcessors [] = new Reference (' ai.agent.structured_output_processor ' );
387
+ $ outputProcessors [] = new Reference (' ai.agent.structured_output_processor ' );
373
388
}
374
389
375
390
// SYSTEM PROMPT
@@ -412,7 +427,6 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
412
427
413
428
$ definition = new Definition (AzureSearchStore::class);
414
429
$ definition
415
- ->setAutowired (true )
416
430
->addTag ('ai.store ' )
417
431
->setArguments ($ arguments );
418
432
@@ -424,7 +438,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
424
438
foreach ($ stores as $ name => $ store ) {
425
439
$ definition = new Definition (ChromaDBStore::class);
426
440
$ definition
427
- ->setAutowired ( true )
441
+ ->setArgument ( ' $client ' , new Reference ( $ store [ ' client_service ' ]) )
428
442
->setArgument ('$collectionName ' , $ store ['collection ' ])
429
443
->addTag ('ai.store ' );
430
444
@@ -450,7 +464,6 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
450
464
451
465
$ definition = new Definition (MongoDBStore::class);
452
466
$ definition
453
- ->setAutowired (true )
454
467
->addTag ('ai.store ' )
455
468
->setArguments ($ arguments );
456
469
@@ -474,7 +487,6 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
474
487
475
488
$ definition = new Definition (PineconeStore::class);
476
489
$ definition
477
- ->setAutowired (true )
478
490
->addTag ('ai.store ' )
479
491
->setArguments ($ arguments );
480
492
0 commit comments