44
55namespace PhpLlm \LlmChainBundle \DependencyInjection ;
66
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 ;
239use PhpLlm \LlmChain \Chain \InputProcessor \SystemPromptInputProcessor ;
24- use PhpLlm \LlmChain \Chain \OutputProcessor ;
10+ use PhpLlm \LlmChain \Chain \InputProcessorInterface ;
11+ use PhpLlm \LlmChain \Chain \OutputProcessorInterface ;
2512use PhpLlm \LlmChain \Chain \StructuredOutput \ChainProcessor as StructureOutputProcessor ;
2613use PhpLlm \LlmChain \Chain \Toolbox \Attribute \AsTool ;
2714use PhpLlm \LlmChain \Chain \Toolbox \ChainProcessor as ToolProcessor ;
2815use 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 ;
3216use 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 ;
4139use PhpLlm \LlmChain \Store \StoreInterface ;
4240use PhpLlm \LlmChain \Store \VectorStoreInterface ;
4341use PhpLlm \LlmChainBundle \Profiler \DataCollector ;
@@ -86,10 +84,6 @@ public function load(array $configs, ContainerBuilder $container): void
8684 if (1 === count ($ config ['chain ' ]) && isset ($ chainName )) {
8785 $ container ->setAlias (ChainInterface::class, 'llm_chain.chain. ' .$ chainName );
8886 }
89- $ llms = array_keys ($ container ->findTaggedServiceIds ('llm_chain.model.language_model ' ));
90- if (1 === count ($ llms )) {
91- $ container ->setAlias (LanguageModel::class, reset ($ llms ));
92- }
9387
9488 foreach ($ config ['store ' ] ?? [] as $ type => $ store ) {
9589 $ this ->processStoreConfig ($ type , $ store , $ container );
@@ -106,10 +100,6 @@ public function load(array $configs, ContainerBuilder $container): void
106100 if (1 === count ($ config ['embedder ' ]) && isset ($ embedderName )) {
107101 $ container ->setAlias (Embedder::class, 'llm_chain.embedder. ' .$ embedderName );
108102 }
109- $ embeddings = array_keys ($ container ->findTaggedServiceIds ('llm_chain.model.embeddings_model ' ));
110- if (1 === count ($ embeddings )) {
111- $ container ->setAlias (EmbeddingsModel::class, reset ($ embeddings ));
112- }
113103
114104 $ container ->registerAttributeForAutoconfiguration (AsTool::class, static function (ChildDefinition $ definition , AsTool $ attribute ): void {
115105 $ definition ->addTag ('llm_chain.tool ' , [
@@ -119,13 +109,13 @@ public function load(array $configs, ContainerBuilder $container): void
119109 ]);
120110 });
121111
122- $ container ->registerForAutoconfiguration (InputProcessor ::class)
112+ $ container ->registerForAutoconfiguration (InputProcessorInterface ::class)
123113 ->addTag ('llm_chain.chain.input_processor ' );
124- $ container ->registerForAutoconfiguration (OutputProcessor ::class)
114+ $ container ->registerForAutoconfiguration (OutputProcessorInterface ::class)
125115 ->addTag ('llm_chain.chain.output_processor ' );
126- $ container ->registerForAutoconfiguration (ModelClient ::class)
116+ $ container ->registerForAutoconfiguration (ModelClientInterface ::class)
127117 ->addTag ('llm_chain.platform.model_client ' );
128- $ container ->registerForAutoconfiguration (ResponseConverter ::class)
118+ $ container ->registerForAutoconfiguration (ResponseConverterInterface ::class)
129119 ->addTag ('llm_chain.platform.response_converter ' );
130120
131121 if (false === $ container ->getParameter ('kernel.debug ' )) {
@@ -253,10 +243,10 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
253243 if ($ config ['tools ' ]['enabled ' ]) {
254244 // Create specific toolbox and process if tools are explicitly defined
255245 if (0 !== count ($ config ['tools ' ]['services ' ])) {
256- $ memoryFactoryDefinition = new Definition (MemoryFactory ::class);
246+ $ memoryFactoryDefinition = new Definition (MemoryToolFactory ::class);
257247 $ container ->setDefinition ('llm_chain.toolbox. ' .$ name .'.memory_factory ' , $ memoryFactoryDefinition );
258248 $ 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)],
260250 ]);
261251 $ container ->setDefinition ('llm_chain.toolbox. ' .$ name .'.chain_factory ' , $ chainFactoryDefinition );
262252
0 commit comments