Skip to content

Commit 56714f3

Browse files
sonnymiltonOskarStark
authored andcommitted
[AI Bundle] Add parsing of model names with colon notation in config
1 parent 2efbd12 commit 56714f3

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/ai-bundle/config/options.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@
252252
throw new InvalidConfigurationException('Model name cannot be empty.');
253253
}
254254

255+
if (isset($parsed['scheme'])) {
256+
$model = $parsed['scheme'].':'.$model;
257+
}
258+
255259
if (isset($parsed['query'])) {
256260
// If options array is also provided, throw an error
257261
if ([] !== $options) {
@@ -659,6 +663,10 @@
659663
throw new InvalidConfigurationException('Model name cannot be empty.');
660664
}
661665

666+
if (isset($parsed['scheme'])) {
667+
$model = $parsed['scheme'].':'.$model;
668+
}
669+
662670
if (isset($parsed['query'])) {
663671
// If options array is also provided, throw an error
664672
if ([] !== $options) {

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,53 @@ public function testComprehensiveMultiAgentHappyPath()
25182518
$this->assertTrue($container->hasDefinition('ai.tool.agent_processor.orchestrator'));
25192519
}
25202520

2521+
#[TestDox('Agent model configuration preserves colon notation in model names (e.g., qwen3:0.6b)')]
2522+
#[TestWith(['qwen3:0.6b'])]
2523+
#[TestWith(['deepseek-r1:70b'])]
2524+
#[TestWith(['qwen3-coder:30b'])]
2525+
#[TestWith(['qwen3:0.6b?think=false'])]
2526+
public function testModelConfigurationWithColonNotation(string $model)
2527+
{
2528+
$container = $this->buildContainer([
2529+
'ai' => [
2530+
'agent' => [
2531+
'test' => [
2532+
'model' => [
2533+
'name' => $model,
2534+
],
2535+
],
2536+
],
2537+
],
2538+
]);
2539+
2540+
$agentDefinition = $container->getDefinition('ai.agent.test');
2541+
2542+
$this->assertSame($model, $agentDefinition->getArgument(1));
2543+
}
2544+
2545+
#[TestDox('Vectorizer model configuration preserves colon notation in model names (e.g., bge-m3:1024)')]
2546+
#[TestWith(['bge-m3:567m'])]
2547+
#[TestWith(['nomic-embed-text:137m-v1.5-fp16'])]
2548+
#[TestWith(['qwen3-embedding:0.6b?normalize=true'])]
2549+
public function testVectorizerConfigurationWithColonNotation(string $model)
2550+
{
2551+
$container = $this->buildContainer([
2552+
'ai' => [
2553+
'vectorizer' => [
2554+
'test' => [
2555+
'model' => [
2556+
'name' => $model,
2557+
],
2558+
],
2559+
],
2560+
],
2561+
]);
2562+
2563+
$definition = $container->getDefinition('ai.vectorizer.test');
2564+
2565+
$this->assertSame($model, $definition->getArgument(1));
2566+
}
2567+
25212568
private function buildContainer(array $configuration): ContainerBuilder
25222569
{
25232570
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)