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
+ use PhpLlm \LlmChain \Chain \Toolbox \MetadataFactory \ChainFactory ;
30
+ use PhpLlm \LlmChain \Chain \Toolbox \MetadataFactory \MemoryFactory ;
31
+ use PhpLlm \LlmChain \Chain \Toolbox \MetadataFactory \ReflectionFactory ;
32
+ use PhpLlm \LlmChain \Chain \Toolbox \Tool \Chain as ChainTool ;
29
33
use PhpLlm \LlmChain \ChainInterface ;
30
34
use PhpLlm \LlmChain \Embedder ;
31
35
use PhpLlm \LlmChain \Model \EmbeddingsModel ;
38
42
use PhpLlm \LlmChain \Store \VectorStoreInterface ;
39
43
use PhpLlm \LlmChainBundle \Profiler \DataCollector ;
40
44
use PhpLlm \LlmChainBundle \Profiler \TraceablePlatform ;
41
- use PhpLlm \LlmChainBundle \Profiler \TraceableToolBox ;
45
+ use PhpLlm \LlmChainBundle \Profiler \TraceableToolbox ;
42
46
use Symfony \Component \Config \FileLocator ;
43
47
use Symfony \Component \DependencyInjection \ChildDefinition ;
44
48
use Symfony \Component \DependencyInjection \ContainerBuilder ;
@@ -126,7 +130,7 @@ public function load(array $configs, ContainerBuilder $container): void
126
130
127
131
if (false === $ container ->getParameter ('kernel.debug ' )) {
128
132
$ container ->removeDefinition (DataCollector::class);
129
- $ container ->removeDefinition (TraceableToolBox ::class);
133
+ $ container ->removeDefinition (TraceableToolbox ::class);
130
134
}
131
135
}
132
136
@@ -247,32 +251,33 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
247
251
248
252
// TOOL & PROCESSOR
249
253
if ($ config ['tools ' ]['enabled ' ]) {
250
- // Create specific tool box and process if tools are explicitly defined
254
+ // Create specific toolbox and process if tools are explicitly defined
251
255
if (0 !== count ($ config ['tools ' ]['services ' ])) {
252
256
$ tools = array_map (static fn (string $ tool ) => new Reference ($ tool ), $ config ['tools ' ]['services ' ]);
257
+
253
258
$ toolboxDefinition = (new ChildDefinition ('llm_chain.toolbox.abstract ' ))
254
259
->replaceArgument ('$tools ' , $ tools );
255
260
$ container ->setDefinition ('llm_chain.toolbox. ' .$ name , $ toolboxDefinition );
256
261
257
262
if ($ config ['fault_tolerant_toolbox ' ]) {
258
263
$ faultTolerantToolboxDefinition = (new Definition ('llm_chain.fault_tolerant_toolbox. ' .$ name ))
259
- ->setClass (FaultTolerantToolBox ::class)
264
+ ->setClass (FaultTolerantToolbox ::class)
260
265
->setAutowired (true )
261
266
->setDecoratedService ('llm_chain.toolbox. ' .$ name );
262
267
$ container ->setDefinition ('llm_chain.fault_tolerant_toolbox. ' .$ name , $ faultTolerantToolboxDefinition );
263
268
}
264
269
265
270
if ($ container ->getParameter ('kernel.debug ' )) {
266
271
$ traceableToolboxDefinition = (new Definition ('llm_chain.traceable_toolbox. ' .$ name ))
267
- ->setClass (TraceableToolBox ::class)
272
+ ->setClass (TraceableToolbox ::class)
268
273
->setAutowired (true )
269
274
->setDecoratedService ('llm_chain.toolbox. ' .$ name )
270
275
->addTag ('llm_chain.traceable_toolbox ' );
271
276
$ container ->setDefinition ('llm_chain.traceable_toolbox. ' .$ name , $ traceableToolboxDefinition );
272
277
}
273
278
274
279
$ toolProcessorDefinition = (new ChildDefinition ('llm_chain.tool.chain_processor.abstract ' ))
275
- ->replaceArgument ('$toolBox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
280
+ ->replaceArgument ('$toolbox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
276
281
$ container ->setDefinition ('llm_chain.tool.chain_processor. ' .$ name , $ toolProcessorDefinition );
277
282
278
283
$ inputProcessors [] = new Reference ('llm_chain.tool.chain_processor. ' .$ name );
@@ -298,7 +303,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
298
303
299
304
if ($ config ['include_tools ' ]) {
300
305
$ systemPromptInputProcessorDefinition
301
- ->setArgument ('$toolBox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
306
+ ->setArgument ('$toolbox ' , new Reference ('llm_chain.toolbox. ' .$ name ));
302
307
}
303
308
304
309
$ inputProcessors [] = $ systemPromptInputProcessorDefinition ;
@@ -424,10 +429,11 @@ private function processEmbedderConfig(int|string $name, array $config, Containe
424
429
$ modelDefinition ->addTag ('llm_chain.model.embeddings_model ' );
425
430
$ container ->setDefinition ('llm_chain.embedder. ' .$ name .'.embeddings ' , $ modelDefinition );
426
431
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 ' ));
432
+ $ definition = new Definition (Embedder::class, [
433
+ '$embeddings ' => new Reference ('llm_chain.embedder. ' .$ name .'.embeddings ' ),
434
+ '$platform ' => new Reference ($ config ['platform ' ]),
435
+ '$store ' => new Reference ($ config ['store ' ]),
436
+ ]);
431
437
432
438
$ container ->setDefinition ('llm_chain.embedder. ' .$ name , $ definition );
433
439
}
0 commit comments