Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 3eb7e4e

Browse files
committed
Add support for Mistral in configuration
1 parent fd48811 commit 3eb7e4e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function getConfigTreeBuilder(): TreeBuilder
4848
->scalarNode('api_key')->isRequired()->end()
4949
->end()
5050
->end()
51+
->arrayNode('mistral')
52+
->children()
53+
->scalarNode('api_key')->isRequired()->end()
54+
->end()
55+
->end()
5156
->end()
5257
->end()
5358
->arrayNode('chain')

src/DependencyInjection/LlmChainExtension.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use PhpLlm\LlmChain\Platform\Bridge\Google\Gemini;
2424
use PhpLlm\LlmChain\Platform\Bridge\Google\PlatformFactory as GooglePlatformFactory;
2525
use PhpLlm\LlmChain\Platform\Bridge\Meta\Llama;
26+
use PhpLlm\LlmChain\Platform\Bridge\Mistral\PlatformFactory as MistralPlatformFactory;
2627
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\Embeddings;
2728
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\GPT;
2829
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\PlatformFactory as OpenAIPlatformFactory;
@@ -202,6 +203,21 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
202203
return;
203204
}
204205

206+
if ('mistral' === $type) {
207+
$platformId = 'llm_chain.platform.mistral';
208+
$definition = (new Definition(Platform::class))
209+
->setFactory(MistralPlatformFactory::class.'::create')
210+
->setAutowired(true)
211+
->setLazy(true)
212+
->addTag('proxy', ['interface' => PlatformInterface::class])
213+
->setArguments(['$apiKey' => $platform['api_key']])
214+
->addTag('llm_chain.platform');
215+
216+
$container->setDefinition($platformId, $definition);
217+
218+
return;
219+
}
220+
205221
throw new \InvalidArgumentException(sprintf('Platform "%s" is not supported for configuration via bundle at this point.', $type));
206222
}
207223

0 commit comments

Comments
 (0)