Skip to content

Commit 906041e

Browse files
committed
[AI Bundle] Fix service registration
1 parent 2c52bb4 commit 906041e

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

.github/workflows/integration-tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ jobs:
106106
- run: composer run-script auto-scripts --no-interaction
107107
working-directory: demo
108108

109+
- run: bin/console cache:clear
110+
working-directory: demo
111+
109112
- name: Run demo tests
110113
working-directory: demo
111114
run: vendor/bin/phpunit

src/ai-bundle/config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
->factory([OpenAiContract::class, 'create'])
7474
->set('ai.platform.contract.anthropic', Contract::class)
7575
->factory([AnthropicContract::class, 'create'])
76-
->set('ai.platform.contract.google', Contract::class)
76+
->set('ai.platform.contract.gemini', Contract::class)
7777
->factory([GeminiContract::class, 'create'])
7878
->set('ai.platform.contract.vertexai.gemini', Contract::class)
7979
->factory([VertexAiGeminiContract::class, 'create'])

src/ai-bundle/src/AiBundle.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
224224
->setArguments([
225225
$platform['api_key'],
226226
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
227-
new Reference('ai.platform.contract.anthropic'),
228227
new Reference('ai.platform.model_catalog.anthropic'),
228+
new Reference('ai.platform.contract.anthropic'),
229229
])
230230
->addTag('ai.platform');
231231

@@ -247,8 +247,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
247247
$config['api_version'],
248248
$config['api_key'],
249249
new Reference($config['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
250-
new Reference('ai.platform.contract.openai'),
251250
new Reference('ai.platform.model_catalog.azure.openai'),
251+
new Reference('ai.platform.contract.azure.openai'),
252252
])
253253
->addTag('ai.platform');
254254

@@ -268,8 +268,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
268268
$platform['api_key'],
269269
$platform['host'],
270270
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
271-
new Reference('ai.platform.contract.default'),
272271
new Reference('ai.platform.model_catalog.elevenlabs'),
272+
new Reference('ai.platform.contract.default'),
273273
])
274274
->addTag('ai.platform');
275275

@@ -287,8 +287,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
287287
->setArguments([
288288
$platform['api_key'],
289289
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
290-
new Reference('ai.platform.contract.google'),
291290
new Reference('ai.platform.model_catalog.gemini'),
291+
new Reference('ai.platform.contract.gemini'),
292292
])
293293
->addTag('ai.platform');
294294

@@ -327,8 +327,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
327327
$platform['location'],
328328
$platform['project_id'],
329329
$httpClient,
330-
new Reference('ai.platform.contract.vertexai', ContainerInterface::NULL_ON_INVALID_REFERENCE),
331330
new Reference('ai.platform.model_catalog.vertexai.gemini'),
331+
new Reference('ai.platform.contract.vertexai.gemini'),
332332
])
333333
->addTag('ai.platform');
334334

@@ -346,6 +346,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
346346
->setArguments([
347347
$platform['api_key'],
348348
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
349+
new Reference('ai.platform.model_catalog.openai'),
349350
new Reference('ai.platform.contract.openai'),
350351
$platform['region'] ?? null,
351352
])
@@ -365,8 +366,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
365366
->setArguments([
366367
$platform['api_key'],
367368
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
368-
new Reference('ai.platform.contract.default'),
369369
new Reference('ai.platform.model_catalog.openrouter'),
370+
new Reference('ai.platform.contract.default'),
370371
])
371372
->addTag('ai.platform');
372373

@@ -384,8 +385,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
384385
->setArguments([
385386
$platform['api_key'],
386387
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
387-
new Reference('ai.platform.contract.default'),
388388
new Reference('ai.platform.model_catalog.mistral'),
389+
new Reference('ai.platform.contract.default'),
389390
])
390391
->addTag('ai.platform');
391392

@@ -403,8 +404,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
403404
->setArguments([
404405
$platform['host_url'],
405406
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
406-
new Reference('ai.platform.contract.default'),
407407
new Reference('ai.platform.model_catalog.lmstudio'),
408+
new Reference('ai.platform.contract.default'),
408409
])
409410
->addTag('ai.platform');
410411

@@ -422,8 +423,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
422423
->setArguments([
423424
$platform['host_url'],
424425
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
425-
new Reference('ai.platform.contract.ollama'),
426426
new Reference('ai.platform.model_catalog.ollama'),
427+
new Reference('ai.platform.contract.ollama'),
427428
])
428429
->addTag('ai.platform');
429430

@@ -442,6 +443,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
442443
$platform['api_key'],
443444
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
444445
new Reference('ai.platform.model_catalog.cerebras'),
446+
new Reference('ai.platform.contract.default'),
445447
])
446448
->addTag('ai.platform');
447449

@@ -460,6 +462,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
460462
$platform['api_key'],
461463
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
462464
new Reference('ai.platform.model_catalog.voyage'),
465+
new Reference('ai.platform.contract.default'),
463466
])
464467
->addTag('ai.platform');
465468

@@ -477,6 +480,7 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
477480
->setArguments([
478481
$platform['api_key'],
479482
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
483+
new Reference('ai.platform.model_catalog.perplexity'),
480484
new Reference('ai.platform.contract.perplexity'),
481485
])
482486
->addTag('ai.platform');
@@ -495,8 +499,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
495499
->setArguments([
496500
$platform['host_url'],
497501
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
498-
new Reference('ai.platform.contract.default'),
499502
new Reference('ai.platform.model_catalog.dockermodelrunner'),
503+
new Reference('ai.platform.contract.default'),
500504
])
501505
->addTag('ai.platform');
502506

@@ -514,8 +518,8 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
514518
->setArguments([
515519
$platform['api_key'],
516520
new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
517-
new Reference('ai.platform.contract.default'),
518521
new Reference('ai.platform.model_catalog.scaleway'),
522+
new Reference('ai.platform.contract.default'),
519523
])
520524
->addTag('ai.platform');
521525

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ public function testOpenAiPlatformWithDefaultRegion()
606606
$definition = $container->getDefinition('ai.platform.openai');
607607
$arguments = $definition->getArguments();
608608

609-
$this->assertCount(4, $arguments);
609+
$this->assertCount(5, $arguments);
610610
$this->assertSame('sk-test-key', $arguments[0]);
611-
$this->assertNull($arguments[3]); // region should be null by default
611+
$this->assertNull($arguments[4]); // region should be null by default
612612
}
613613

614614
#[TestWith(['EU'])]
@@ -632,9 +632,9 @@ public function testOpenAiPlatformWithRegion(?string $region)
632632
$definition = $container->getDefinition('ai.platform.openai');
633633
$arguments = $definition->getArguments();
634634

635-
$this->assertCount(4, $arguments);
635+
$this->assertCount(5, $arguments);
636636
$this->assertSame('sk-test-key', $arguments[0]);
637-
$this->assertSame($region, $arguments[3]);
637+
$this->assertSame($region, $arguments[4]);
638638
}
639639

640640
public function testOpenAiPlatformWithInvalidRegion()
@@ -671,12 +671,14 @@ public function testPerplexityPlatformConfiguration()
671671
$definition = $container->getDefinition('ai.platform.perplexity');
672672
$arguments = $definition->getArguments();
673673

674-
$this->assertCount(3, $arguments);
674+
$this->assertCount(4, $arguments);
675675
$this->assertSame('pplx-test-key', $arguments[0]);
676676
$this->assertInstanceOf(Reference::class, $arguments[1]);
677677
$this->assertSame('http_client', (string) $arguments[1]);
678678
$this->assertInstanceOf(Reference::class, $arguments[2]);
679-
$this->assertSame('ai.platform.contract.perplexity', (string) $arguments[2]);
679+
$this->assertSame('ai.platform.model_catalog.perplexity', (string) $arguments[2]);
680+
$this->assertInstanceOf(Reference::class, $arguments[3]);
681+
$this->assertSame('ai.platform.contract.perplexity', (string) $arguments[3]);
680682
}
681683

682684
#[TestDox('System prompt with array structure works correctly')]

src/platform/src/Bridge/Cerebras/PlatformFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\AI\Platform\Bridge\Cerebras;
1313

14+
use Symfony\AI\Platform\Contract;
1415
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
1516
use Symfony\AI\Platform\Platform;
1617
use Symfony\Component\HttpClient\EventSourceHttpClient;
@@ -25,13 +26,15 @@ public static function create(
2526
#[\SensitiveParameter] string $apiKey,
2627
?HttpClientInterface $httpClient = null,
2728
ModelCatalogInterface $modelCatalog = new ModelCatalog(),
29+
?Contract $contract = null,
2830
): Platform {
2931
$httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient);
3032

3133
return new Platform(
3234
[new ModelClient($httpClient, $apiKey)],
3335
[new ResultConverter()],
3436
$modelCatalog,
37+
$contract,
3538
);
3639
}
3740
}

src/platform/src/Bridge/Voyage/PlatformFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public static function create(
3030
): Platform {
3131
$httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient);
3232

33-
return new Platform([new ModelClient($httpClient, $apiKey)], [new ResultConverter()], $modelCatalog, $contract);
33+
return new Platform(
34+
[new ModelClient($httpClient, $apiKey)],
35+
[new ResultConverter()],
36+
$modelCatalog,
37+
$contract,
38+
);
3439
}
3540
}

0 commit comments

Comments
 (0)