Skip to content

Commit 4845bbd

Browse files
committed
feat(ai): integrate Albert platform support
- Add Albert platform configuration and service definitions. - Update ModelCatalog with `albert-large` support. - Make platform factory accept a customizable ModelCatalog instance.
1 parent 3b12db8 commit 4845bbd

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/ai-bundle/config/services.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\AI\Chat\Command\DropStoreCommand as DropMessageStoreCommand;
2525
use Symfony\AI\Chat\Command\SetupStoreCommand as SetupMessageStoreCommand;
2626
use Symfony\AI\Platform\Bridge\AiMlApi\ModelCatalog as AiMlApiModelCatalog;
27+
use Symfony\AI\Platform\Bridge\Albert\ModelCatalog as AlbertModelCatalog;
2728
use Symfony\AI\Platform\Bridge\Anthropic\Contract\AnthropicContract;
2829
use Symfony\AI\Platform\Bridge\Anthropic\ModelCatalog as AnthropicModelCatalog;
2930
use Symfony\AI\Platform\Bridge\Anthropic\TokenOutputProcessor as AnthropicTokenOutputProcessor;
@@ -83,6 +84,7 @@
8384

8485
// model catalog
8586
->set('ai.platform.model_catalog.aimlapi', AiMlApiModelCatalog::class)
87+
->set('ai.platform.model_catalog.albert', AlbertModelCatalog::class)
8688
->set('ai.platform.model_catalog.anthropic', AnthropicModelCatalog::class)
8789
->set('ai.platform.model_catalog.cerebras', CerebrasModelCatalog::class)
8890
->set('ai.platform.model_catalog.deepseek', DeepSeekModelCatalog::class)

src/ai-bundle/src/AiBundle.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,26 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
246246
*/
247247
private function processPlatformConfig(string $type, array $platform, ContainerBuilder $container): void
248248
{
249+
if ('albert' === $type) {
250+
$platformId = 'ai.platform.albert';
251+
$definition = (new Definition(Platform::class))
252+
->setFactory(AlbertPlatformFactory::class.'::create')
253+
->setLazy(true)
254+
->addTag('proxy', ['interface' => PlatformInterface::class])
255+
->setArguments([
256+
$platform['api_key'],
257+
$platform['base_url'],
258+
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
259+
new Reference('ai.platform.model_catalog.albert'),
260+
new Reference('event_dispatcher'),
261+
])
262+
->addTag('ai.platform', ['name' => 'albert']);
263+
264+
$container->setDefinition($platformId, $definition);
265+
266+
return;
267+
}
268+
249269
if ('anthropic' === $type) {
250270
$platformId = 'ai.platform.anthropic';
251271
$definition = (new Definition(Platform::class))

src/platform/src/Bridge/Albert/PlatformFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
1717
use Symfony\AI\Platform\Contract;
1818
use Symfony\AI\Platform\Exception\InvalidArgumentException;
19+
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
1920
use Symfony\AI\Platform\Platform;
2021
use Symfony\Component\HttpClient\EventSourceHttpClient;
2122
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -29,6 +30,7 @@ public static function create(
2930
#[\SensitiveParameter] string $apiKey,
3031
string $baseUrl,
3132
?HttpClientInterface $httpClient = null,
33+
ModelCatalogInterface $modelCatalog = new ModelCatalog(),
3234
?EventDispatcherInterface $eventDispatcher = null,
3335
): Platform {
3436
if (!str_starts_with($baseUrl, 'https://')) {
@@ -52,7 +54,7 @@ public static function create(
5254
new EmbeddingsModelClient($httpClient, $apiKey, $baseUrl),
5355
],
5456
[new Gpt\ResultConverter(), new Embeddings\ResultConverter()],
55-
new ModelCatalog(),
57+
$modelCatalog,
5658
Contract::create(),
5759
$eventDispatcher,
5860
);

0 commit comments

Comments
 (0)