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

Commit b9eddd7

Browse files
authored
feat: Add support for Mistral in configuration (#89)
feat(config): Add support for Mistral in configuration
1 parent fd48811 commit b9eddd7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
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\Mistral;
27+
use PhpLlm\LlmChain\Platform\Bridge\Mistral\PlatformFactory as MistralPlatformFactory;
2628
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\Embeddings;
2729
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\GPT;
2830
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\PlatformFactory as OpenAIPlatformFactory;
@@ -202,6 +204,21 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
202204
return;
203205
}
204206

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

@@ -218,6 +235,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
218235
'claude' => Claude::class,
219236
'llama' => Llama::class,
220237
'gemini' => Gemini::class,
238+
'mistral' => Mistral::class,
221239
default => throw new \InvalidArgumentException(sprintf('Model "%s" is not supported.', $modelName)),
222240
};
223241
$modelDefinition = new Definition($modelClass);

0 commit comments

Comments
 (0)