Skip to content

Commit bb48e7e

Browse files
committed
Wire Docker Model Runner platform bridge into Ai Bundle
1 parent 312b233 commit bb48e7e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/ai-bundle/config/options.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
->scalarNode('api_key')->isRequired()->end()
107107
->end()
108108
->end()
109+
->arrayNode('dockermodelrunner')
110+
->children()
111+
->scalarNode('host_url')->defaultValue('http://127.0.0.1:12434')->end()
112+
->end()
113+
->end()
109114
->end()
110115
->end()
111116
->arrayNode('agent')

src/ai-bundle/src/AiBundle.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory;
3434
use Symfony\AI\Platform\Bridge\Azure\OpenAi\PlatformFactory as AzureOpenAiPlatformFactory;
3535
use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory;
36+
use Symfony\AI\Platform\Bridge\DockerModelRunner\PlatformFactory as DockerModelRunnerPlatformFactory;
3637
use Symfony\AI\Platform\Bridge\ElevenLabs\PlatformFactory as ElevenLabsPlatformFactory;
3738
use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory as GeminiPlatformFactory;
3839
use Symfony\AI\Platform\Bridge\LmStudio\PlatformFactory as LmStudioPlatformFactory;
@@ -472,6 +473,24 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
472473
return;
473474
}
474475

476+
if ('dockermodelrunner' === $type) {
477+
$platformId = 'ai.platform.dockermodelrunner';
478+
$definition = (new Definition(Platform::class))
479+
->setFactory(DockerModelRunnerPlatformFactory::class.'::create')
480+
->setLazy(true)
481+
->addTag('proxy', ['interface' => PlatformInterface::class])
482+
->setArguments([
483+
$platform['host_url'],
484+
new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
485+
new Reference('ai.platform.contract.default'),
486+
])
487+
->addTag('ai.platform');
488+
489+
$container->setDefinition($platformId, $definition);
490+
491+
return;
492+
}
493+
475494
throw new InvalidArgumentException(\sprintf('Platform "%s" is not supported for configuration via bundle at this point.', $type));
476495
}
477496

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ private function getFullConfig(): array
10611061
'location' => 'global',
10621062
'project_id' => '123',
10631063
],
1064+
'dockermodelrunner' => [
1065+
'host_url' => 'http://127.0.0.1:12434',
1066+
],
10641067
],
10651068
'agent' => [
10661069
'my_chat_agent' => [

0 commit comments

Comments
 (0)