4
4
5
5
namespace PhpLlm \LlmChainBundle \DependencyInjection ;
6
6
7
- use PhpLlm \LlmChain \Bridge \Anthropic \Claude ;
8
- use PhpLlm \LlmChain \Bridge \Anthropic \PlatformFactory as AnthropicPlatformFactory ;
9
- use PhpLlm \LlmChain \Bridge \Azure \OpenAI \PlatformFactory as AzureOpenAIPlatformFactory ;
10
- use PhpLlm \LlmChain \Bridge \Azure \Store \SearchStore as AzureSearchStore ;
11
- use PhpLlm \LlmChain \Bridge \ChromaDB \Store as ChromaDBStore ;
12
- use PhpLlm \LlmChain \Bridge \Google \Gemini ;
13
- use PhpLlm \LlmChain \Bridge \Google \PlatformFactory as GooglePlatformFactory ;
14
- use PhpLlm \LlmChain \Bridge \Meta \Llama ;
15
- use PhpLlm \LlmChain \Bridge \MongoDB \Store as MongoDBStore ;
16
- use PhpLlm \LlmChain \Bridge \OpenAI \Embeddings ;
17
- use PhpLlm \LlmChain \Bridge \OpenAI \GPT ;
18
- use PhpLlm \LlmChain \Bridge \OpenAI \PlatformFactory as OpenAIPlatformFactory ;
19
- use PhpLlm \LlmChain \Bridge \Pinecone \Store as PineconeStore ;
20
- use PhpLlm \LlmChain \Bridge \Voyage \Voyage ;
21
- use PhpLlm \LlmChain \Chain ;
22
- use PhpLlm \LlmChain \Chain \InputProcessor ;
7
+ use PhpLlm \LlmChain \Chain \Chain ;
8
+ use PhpLlm \LlmChain \Chain \ChainInterface ;
23
9
use PhpLlm \LlmChain \Chain \InputProcessor \SystemPromptInputProcessor ;
24
- use PhpLlm \LlmChain \Chain \OutputProcessor ;
10
+ use PhpLlm \LlmChain \Chain \InputProcessorInterface ;
11
+ use PhpLlm \LlmChain \Chain \OutputProcessorInterface ;
25
12
use PhpLlm \LlmChain \Chain \StructuredOutput \ChainProcessor as StructureOutputProcessor ;
26
13
use PhpLlm \LlmChain \Chain \Toolbox \Attribute \AsTool ;
27
14
use PhpLlm \LlmChain \Chain \Toolbox \ChainProcessor as ToolProcessor ;
28
15
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
16
use PhpLlm \LlmChain \Chain \Toolbox \Tool \Chain as ChainTool ;
33
- use PhpLlm \LlmChain \ChainInterface ;
34
- use PhpLlm \LlmChain \Embedder ;
35
- use PhpLlm \LlmChain \Model \EmbeddingsModel ;
36
- use PhpLlm \LlmChain \Model \LanguageModel ;
37
- use PhpLlm \LlmChain \Platform ;
38
- use PhpLlm \LlmChain \Platform \ModelClient ;
39
- use PhpLlm \LlmChain \Platform \ResponseConverter ;
40
- use PhpLlm \LlmChain \PlatformInterface ;
17
+ use PhpLlm \LlmChain \Chain \Toolbox \ToolFactory \ChainFactory ;
18
+ use PhpLlm \LlmChain \Chain \Toolbox \ToolFactory \MemoryToolFactory ;
19
+ use PhpLlm \LlmChain \Chain \Toolbox \ToolFactory \ReflectionToolFactory ;
20
+ use PhpLlm \LlmChain \Platform \Bridge \Anthropic \Claude ;
21
+ use PhpLlm \LlmChain \Platform \Bridge \Anthropic \PlatformFactory as AnthropicPlatformFactory ;
22
+ use PhpLlm \LlmChain \Platform \Bridge \Azure \OpenAI \PlatformFactory as AzureOpenAIPlatformFactory ;
23
+ use PhpLlm \LlmChain \Platform \Bridge \Google \Gemini ;
24
+ use PhpLlm \LlmChain \Platform \Bridge \Google \PlatformFactory as GooglePlatformFactory ;
25
+ use PhpLlm \LlmChain \Platform \Bridge \Meta \Llama ;
26
+ use PhpLlm \LlmChain \Platform \Bridge \OpenAI \Embeddings ;
27
+ use PhpLlm \LlmChain \Platform \Bridge \OpenAI \GPT ;
28
+ use PhpLlm \LlmChain \Platform \Bridge \OpenAI \PlatformFactory as OpenAIPlatformFactory ;
29
+ use PhpLlm \LlmChain \Platform \Bridge \Voyage \Voyage ;
30
+ use PhpLlm \LlmChain \Platform \ModelClientInterface ;
31
+ use PhpLlm \LlmChain \Platform \Platform ;
32
+ use PhpLlm \LlmChain \Platform \PlatformInterface ;
33
+ use PhpLlm \LlmChain \Platform \ResponseConverterInterface ;
34
+ use PhpLlm \LlmChain \Store \Bridge \Azure \SearchStore as AzureSearchStore ;
35
+ use PhpLlm \LlmChain \Store \Bridge \ChromaDB \Store as ChromaDBStore ;
36
+ use PhpLlm \LlmChain \Store \Bridge \MongoDB \Store as MongoDBStore ;
37
+ use PhpLlm \LlmChain \Store \Bridge \Pinecone \Store as PineconeStore ;
38
+ use PhpLlm \LlmChain \Store \Embedder ;
41
39
use PhpLlm \LlmChain \Store \StoreInterface ;
42
40
use PhpLlm \LlmChain \Store \VectorStoreInterface ;
43
41
use PhpLlm \LlmChainBundle \Profiler \DataCollector ;
@@ -86,10 +84,6 @@ public function load(array $configs, ContainerBuilder $container): void
86
84
if (1 === count ($ config ['chain ' ]) && isset ($ chainName )) {
87
85
$ container ->setAlias (ChainInterface::class, 'llm_chain.chain. ' .$ chainName );
88
86
}
89
- $ llms = array_keys ($ container ->findTaggedServiceIds ('llm_chain.model.language_model ' ));
90
- if (1 === count ($ llms )) {
91
- $ container ->setAlias (LanguageModel::class, reset ($ llms ));
92
- }
93
87
94
88
foreach ($ config ['store ' ] ?? [] as $ type => $ store ) {
95
89
$ this ->processStoreConfig ($ type , $ store , $ container );
@@ -106,10 +100,6 @@ public function load(array $configs, ContainerBuilder $container): void
106
100
if (1 === count ($ config ['embedder ' ]) && isset ($ embedderName )) {
107
101
$ container ->setAlias (Embedder::class, 'llm_chain.embedder. ' .$ embedderName );
108
102
}
109
- $ embeddings = array_keys ($ container ->findTaggedServiceIds ('llm_chain.model.embeddings_model ' ));
110
- if (1 === count ($ embeddings )) {
111
- $ container ->setAlias (EmbeddingsModel::class, reset ($ embeddings ));
112
- }
113
103
114
104
$ container ->registerAttributeForAutoconfiguration (AsTool::class, static function (ChildDefinition $ definition , AsTool $ attribute ): void {
115
105
$ definition ->addTag ('llm_chain.tool ' , [
@@ -119,13 +109,13 @@ public function load(array $configs, ContainerBuilder $container): void
119
109
]);
120
110
});
121
111
122
- $ container ->registerForAutoconfiguration (InputProcessor ::class)
112
+ $ container ->registerForAutoconfiguration (InputProcessorInterface ::class)
123
113
->addTag ('llm_chain.chain.input_processor ' );
124
- $ container ->registerForAutoconfiguration (OutputProcessor ::class)
114
+ $ container ->registerForAutoconfiguration (OutputProcessorInterface ::class)
125
115
->addTag ('llm_chain.chain.output_processor ' );
126
- $ container ->registerForAutoconfiguration (ModelClient ::class)
116
+ $ container ->registerForAutoconfiguration (ModelClientInterface ::class)
127
117
->addTag ('llm_chain.platform.model_client ' );
128
- $ container ->registerForAutoconfiguration (ResponseConverter ::class)
118
+ $ container ->registerForAutoconfiguration (ResponseConverterInterface ::class)
129
119
->addTag ('llm_chain.platform.response_converter ' );
130
120
131
121
if (false === $ container ->getParameter ('kernel.debug ' )) {
@@ -253,10 +243,10 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
253
243
if ($ config ['tools ' ]['enabled ' ]) {
254
244
// Create specific toolbox and process if tools are explicitly defined
255
245
if (0 !== count ($ config ['tools ' ]['services ' ])) {
256
- $ memoryFactoryDefinition = new Definition (MemoryFactory ::class);
246
+ $ memoryFactoryDefinition = new Definition (MemoryToolFactory ::class);
257
247
$ container ->setDefinition ('llm_chain.toolbox. ' .$ name .'.memory_factory ' , $ memoryFactoryDefinition );
258
248
$ chainFactoryDefinition = new Definition (ChainFactory::class, [
259
- '$factories ' => [new Reference ('llm_chain.toolbox. ' .$ name .'.memory_factory ' ), new Reference (ReflectionFactory ::class)],
249
+ '$factories ' => [new Reference ('llm_chain.toolbox. ' .$ name .'.memory_factory ' ), new Reference (ReflectionToolFactory ::class)],
260
250
]);
261
251
$ container ->setDefinition ('llm_chain.toolbox. ' .$ name .'.chain_factory ' , $ chainFactoryDefinition );
262
252
0 commit comments