23
23
use PhpLlm \LlmChain \Chain \InputProcessor \SystemPromptInputProcessor ;
24
24
use PhpLlm \LlmChain \Chain \OutputProcessor ;
25
25
use PhpLlm \LlmChain \Chain \StructuredOutput \ChainProcessor as StructureOutputProcessor ;
26
- use PhpLlm \LlmChain \Chain \ToolBox \Attribute \AsTool ;
27
- use PhpLlm \LlmChain \Chain \ToolBox \ChainProcessor as ToolProcessor ;
28
- use PhpLlm \LlmChain \Chain \ToolBox \ FaultTolerantToolBox ;
26
+ use PhpLlm \LlmChain \Chain \Toolbox \Attribute \AsTool ;
27
+ use PhpLlm \LlmChain \Chain \Toolbox \ChainProcessor as ToolProcessor ;
28
+ use PhpLlm \LlmChain \Chain \Toolbox \ FaultTolerantToolbox ;
29
29
use PhpLlm \LlmChain \ChainInterface ;
30
30
use PhpLlm \LlmChain \Embedder ;
31
31
use PhpLlm \LlmChain \Model \EmbeddingsModel ;
38
38
use PhpLlm \LlmChain \Store \VectorStoreInterface ;
39
39
use PhpLlm \LlmChainBundle \Profiler \DataCollector ;
40
40
use PhpLlm \LlmChainBundle \Profiler \TraceablePlatform ;
41
- use PhpLlm \LlmChainBundle \Profiler \TraceableToolBox ;
41
+ use PhpLlm \LlmChainBundle \Profiler \TraceableToolbox ;
42
42
use Symfony \Component \Config \FileLocator ;
43
43
use Symfony \Component \DependencyInjection \ChildDefinition ;
44
44
use Symfony \Component \DependencyInjection \ContainerBuilder ;
@@ -126,7 +126,7 @@ public function load(array $configs, ContainerBuilder $container): void
126
126
127
127
if (false === $ container ->getParameter ('kernel.debug ' )) {
128
128
$ container ->removeDefinition (DataCollector::class);
129
- $ container ->removeDefinition (TraceableToolBox ::class);
129
+ $ container ->removeDefinition (TraceableToolbox ::class);
130
130
}
131
131
}
132
132
@@ -247,32 +247,33 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
247
247
248
248
// TOOL & PROCESSOR
249
249
if ($ config ['tools ' ]['enabled ' ]) {
250
- // Create specific tool box and process if tools are explicitly defined
250
+ // Create specific toolbox and process if tools are explicitly defined
251
251
if (0 !== count ($ config ['tools ' ]['services ' ])) {
252
252
$ tools = array_map (static fn (string $ tool ) => new Reference ($ tool ), $ config ['tools ' ]['services ' ]);
253
+
253
254
$ toolboxDefinition = (new ChildDefinition ('llm_chain.toolbox.abstract ' ))
254
255
->replaceArgument ('$tools ' , $ tools );
255
256
$ container ->setDefinition ('llm_chain.toolbox. ' .$ name , $ toolboxDefinition );
256
257
257
258
if ($ config ['fault_tolerant_toolbox ' ]) {
258
259
$ faultTolerantToolboxDefinition = (new Definition ('llm_chain.fault_tolerant_toolbox. ' .$ name ))
259
- ->setClass (FaultTolerantToolBox ::class)
260
+ ->setClass (FaultTolerantToolbox ::class)
260
261
->setAutowired (true )
261
262
->setDecoratedService ('llm_chain.toolbox. ' .$ name );
262
263
$ container ->setDefinition ('llm_chain.fault_tolerant_toolbox. ' .$ name , $ faultTolerantToolboxDefinition );
263
264
}
264
265
265
266
if ($ container ->getParameter ('kernel.debug ' )) {
266
267
$ traceableToolboxDefinition = (new Definition ('llm_chain.traceable_toolbox. ' .$ name ))
267
- ->setClass (TraceableToolBox ::class)
268
+ ->setClass (TraceableToolbox ::class)
268
269
->setAutowired (true )
269
270
->setDecoratedService ('llm_chain.toolbox. ' .$ name )
270
271
->addTag ('llm_chain.traceable_toolbox ' );
271
272
$ container ->setDefinition ('llm_chain.traceable_toolbox. ' .$ name , $ traceableToolboxDefinition );
272
273
}
273
274
274
275
$ toolProcessorDefinition = (new ChildDefinition ('llm_chain.tool.chain_processor.abstract ' ))
275
- ->replaceArgument ('$toolBox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
276
+ ->replaceArgument ('$toolbox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
276
277
$ container ->setDefinition ('llm_chain.tool.chain_processor. ' .$ name , $ toolProcessorDefinition );
277
278
278
279
$ inputProcessors [] = new Reference ('llm_chain.tool.chain_processor. ' .$ name );
@@ -298,7 +299,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
298
299
299
300
if ($ config ['include_tools ' ]) {
300
301
$ systemPromptInputProcessorDefinition
301
- ->setArgument ('$toolBox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
302
+ ->setArgument ('$toolbox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
302
303
}
303
304
304
305
$ inputProcessors [] = $ systemPromptInputProcessorDefinition ;
@@ -424,10 +425,11 @@ private function processEmbedderConfig(int|string $name, array $config, Containe
424
425
$ modelDefinition ->addTag ('llm_chain.model.embeddings_model ' );
425
426
$ container ->setDefinition ('llm_chain.embedder. ' .$ name .'.embeddings ' , $ modelDefinition );
426
427
427
- $ definition = (new ChildDefinition ('llm_chain.embedder.abstract ' ))
428
- ->replaceArgument ('$platform ' , new Reference ($ config ['platform ' ]))
429
- ->replaceArgument ('$store ' , new Reference ($ config ['store ' ]))
430
- ->replaceArgument ('$embeddings ' , new Reference ('llm_chain.embedder. ' .$ name .'.embeddings ' ));
428
+ $ definition = new Definition (Embedder::class, [
429
+ '$embeddings ' => new Reference ('llm_chain.embedder. ' .$ name .'.embeddings ' ),
430
+ '$platform ' => new Reference ($ config ['platform ' ]),
431
+ '$store ' => new Reference ($ config ['store ' ]),
432
+ ]);
431
433
432
434
$ container ->setDefinition ('llm_chain.embedder. ' .$ name , $ definition );
433
435
}
0 commit comments