Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ai-bundle/config/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
->children()
->arrayNode('platform')
->children()
->arrayNode('albert')
->children()
->stringNode('api_key')->isRequired()->end()
->stringNode('base_url')->isRequired()->end()
->stringNode('http_client')
->defaultValue('http_client')
->info('Service ID of the HTTP client to use')
->end()
->end()
->end()
->arrayNode('anthropic')
->children()
->stringNode('api_key')->isRequired()->end()
Expand Down
2 changes: 2 additions & 0 deletions src/ai-bundle/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Symfony\AI\Chat\Command\DropStoreCommand as DropMessageStoreCommand;
use Symfony\AI\Chat\Command\SetupStoreCommand as SetupMessageStoreCommand;
use Symfony\AI\Platform\Bridge\AiMlApi\ModelCatalog as AiMlApiModelCatalog;
use Symfony\AI\Platform\Bridge\Albert\ModelCatalog as AlbertModelCatalog;
use Symfony\AI\Platform\Bridge\Anthropic\Contract\AnthropicContract;
use Symfony\AI\Platform\Bridge\Anthropic\ModelCatalog as AnthropicModelCatalog;
use Symfony\AI\Platform\Bridge\Anthropic\TokenOutputProcessor as AnthropicTokenOutputProcessor;
Expand Down Expand Up @@ -83,6 +84,7 @@

// model catalog
->set('ai.platform.model_catalog.aimlapi', AiMlApiModelCatalog::class)
->set('ai.platform.model_catalog.albert', AlbertModelCatalog::class)
->set('ai.platform.model_catalog.anthropic', AnthropicModelCatalog::class)
->set('ai.platform.model_catalog.cerebras', CerebrasModelCatalog::class)
->set('ai.platform.model_catalog.deepseek', DeepSeekModelCatalog::class)
Expand Down
21 changes: 21 additions & 0 deletions src/ai-bundle/src/AiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Symfony\AI\Chat\Bridge\Meilisearch\MessageStore as MeilisearchMessageStore;
use Symfony\AI\Chat\Bridge\Pogocache\MessageStore as PogocacheMessageStore;
use Symfony\AI\Chat\MessageStoreInterface;
use Symfony\AI\Platform\Bridge\Albert\PlatformFactory as AlbertPlatformFactory;
use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory;
use Symfony\AI\Platform\Bridge\Azure\OpenAi\PlatformFactory as AzureOpenAiPlatformFactory;
use Symfony\AI\Platform\Bridge\Cerebras\PlatformFactory as CerebrasPlatformFactory;
Expand Down Expand Up @@ -246,6 +247,26 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
*/
private function processPlatformConfig(string $type, array $platform, ContainerBuilder $container): void
{
if ('albert' === $type) {
$platformId = 'ai.platform.albert';
$definition = (new Definition(Platform::class))
->setFactory(AlbertPlatformFactory::class.'::create')
->setLazy(true)
->addTag('proxy', ['interface' => PlatformInterface::class])
->setArguments([
$platform['api_key'],
$platform['base_url'],
new Reference($platform['http_client'], ContainerInterface::NULL_ON_INVALID_REFERENCE),
new Reference('ai.platform.model_catalog.albert'),
new Reference('event_dispatcher'),
])
->addTag('ai.platform', ['name' => 'albert']);

$container->setDefinition($platformId, $definition);

return;
}

if ('anthropic' === $type) {
$platformId = 'ai.platform.anthropic';
$definition = (new Definition(Platform::class))
Expand Down
4 changes: 4 additions & 0 deletions src/ai-bundle/tests/DependencyInjection/AiBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,10 @@ private function getFullConfig(): array
'anthropic' => [
'api_key' => 'anthropic_key_full',
],
'albert' => [
'api_key' => 'albert-test-key',
'base_url' => 'https://albert.api.etalab.gouv.fr/v1',
],
'azure' => [
'my_azure_instance' => [
'api_key' => 'azure_key_full',
Expand Down
4 changes: 3 additions & 1 deletion src/platform/src/Bridge/Albert/PlatformFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
use Symfony\AI\Platform\Contract;
use Symfony\AI\Platform\Exception\InvalidArgumentException;
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
use Symfony\AI\Platform\Platform;
use Symfony\Component\HttpClient\EventSourceHttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand All @@ -29,6 +30,7 @@ public static function create(
#[\SensitiveParameter] string $apiKey,
string $baseUrl,
?HttpClientInterface $httpClient = null,
ModelCatalogInterface $modelCatalog = new ModelCatalog(),
?EventDispatcherInterface $eventDispatcher = null,
): Platform {
if (!str_starts_with($baseUrl, 'https://')) {
Expand All @@ -52,7 +54,7 @@ public static function create(
new EmbeddingsModelClient($httpClient, $apiKey, $baseUrl),
],
[new Gpt\ResultConverter(), new Embeddings\ResultConverter()],
new ModelCatalog(),
$modelCatalog,
Contract::create(),
$eventDispatcher,
);
Expand Down