99use PhpLlm \LlmChain \Bridge \Azure \OpenAI \PlatformFactory as AzureOpenAIPlatformFactory ;
1010use PhpLlm \LlmChain \Bridge \Azure \Store \SearchStore as AzureSearchStore ;
1111use PhpLlm \LlmChain \Bridge \ChromaDB \Store as ChromaDBStore ;
12+ use PhpLlm \LlmChain \Bridge \Google \Gemini ;
13+ use PhpLlm \LlmChain \Bridge \Google \PlatformFactory as GooglePlatformFactory ;
1214use PhpLlm \LlmChain \Bridge \Meta \Llama ;
1315use PhpLlm \LlmChain \Bridge \MongoDB \Store as MongoDBStore ;
1416use PhpLlm \LlmChain \Bridge \OpenAI \Embeddings ;
2325use PhpLlm \LlmChain \Chain \StructuredOutput \ChainProcessor as StructureOutputProcessor ;
2426use PhpLlm \LlmChain \Chain \ToolBox \Attribute \AsTool ;
2527use PhpLlm \LlmChain \Chain \ToolBox \ChainProcessor as ToolProcessor ;
28+ use PhpLlm \LlmChain \Chain \ToolBox \FaultTolerantToolBox ;
2629use PhpLlm \LlmChain \ChainInterface ;
2730use PhpLlm \LlmChain \Embedder ;
2831use PhpLlm \LlmChain \Model \EmbeddingsModel ;
@@ -132,16 +135,22 @@ public function load(array $configs, ContainerBuilder $container): void
132135 */
133136 private function processPlatformConfig (string $ type , array $ platform , ContainerBuilder $ container ): void
134137 {
135- if ('openai ' === $ type ) {
136- $ platformId = 'llm_chain.platform.openai ' ;
138+ if ('anthropic ' === $ type ) {
139+ $ platformId = 'llm_chain.platform.anthropic ' ;
137140 $ definition = (new Definition (Platform::class))
138- ->setFactory (OpenAIPlatformFactory ::class.'::create ' )
141+ ->setFactory (AnthropicPlatformFactory ::class.'::create ' )
139142 ->setAutowired (true )
140143 ->setLazy (true )
141144 ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
142- ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
145+ ->setArguments ([
146+ '$apiKey ' => $ platform ['api_key ' ],
147+ ])
143148 ->addTag ('llm_chain.platform ' );
144149
150+ if (isset ($ platform ['version ' ])) {
151+ $ definition ->replaceArgument ('$version ' , $ platform ['version ' ]);
152+ }
153+
145154 $ container ->setDefinition ($ platformId , $ definition );
146155
147156 return ;
@@ -169,21 +178,30 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
169178 return ;
170179 }
171180
172- if ('anthropic ' === $ type ) {
173- $ platformId = 'llm_chain.platform.anthropic ' ;
181+ if ('google ' === $ type ) {
182+ $ platformId = 'llm_chain.platform.google ' ;
174183 $ definition = (new Definition (Platform::class))
175- ->setFactory (AnthropicPlatformFactory ::class.'::create ' )
184+ ->setFactory (GooglePlatformFactory ::class.'::create ' )
176185 ->setAutowired (true )
177186 ->setLazy (true )
178187 ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
179- ->setArguments ([
180- '$apiKey ' => $ platform ['api_key ' ],
181- ])
188+ ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
182189 ->addTag ('llm_chain.platform ' );
183190
184- if (isset ($ platform ['version ' ])) {
185- $ definition ->replaceArgument ('$version ' , $ platform ['version ' ]);
186- }
191+ $ container ->setDefinition ($ platformId , $ definition );
192+
193+ return ;
194+ }
195+
196+ if ('openai ' === $ type ) {
197+ $ platformId = 'llm_chain.platform.openai ' ;
198+ $ definition = (new Definition (Platform::class))
199+ ->setFactory (OpenAIPlatformFactory::class.'::create ' )
200+ ->setAutowired (true )
201+ ->setLazy (true )
202+ ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
203+ ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
204+ ->addTag ('llm_chain.platform ' );
187205
188206 $ container ->setDefinition ($ platformId , $ definition );
189207
@@ -205,6 +223,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
205223 'gpt ' => GPT ::class,
206224 'claude ' => Claude::class,
207225 'llama ' => Llama::class,
226+ 'gemini ' => Gemini::class,
208227 default => throw new \InvalidArgumentException (sprintf ('Model "%s" is not supported. ' , $ modelName )),
209228 };
210229 $ llmDefinition = new Definition ($ llmClass );
@@ -235,6 +254,14 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
235254 ->replaceArgument ('$tools ' , $ tools );
236255 $ container ->setDefinition ('llm_chain.toolbox. ' .$ name , $ toolboxDefinition );
237256
257+ if ($ config ['fault_tolerant_toolbox ' ]) {
258+ $ faultTolerantToolboxDefinition = (new Definition ('llm_chain.fault_tolerant_toolbox. ' .$ name ))
259+ ->setClass (FaultTolerantToolBox::class)
260+ ->setAutowired (true )
261+ ->setDecoratedService ('llm_chain.toolbox. ' .$ name );
262+ $ container ->setDefinition ('llm_chain.fault_tolerant_toolbox. ' .$ name , $ faultTolerantToolboxDefinition );
263+ }
264+
238265 if ($ container ->getParameter ('kernel.debug ' )) {
239266 $ traceableToolboxDefinition = (new Definition ('llm_chain.traceable_toolbox. ' .$ name ))
240267 ->setClass (TraceableToolBox::class)
0 commit comments