Skip to content

Commit b414b46

Browse files
committed
[TASK] Update symfony bridge and declare conflict with <0.8
1 parent 1fbc093 commit b414b46

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

Classes/DependencyInjection/SymfonyAiCompilerPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* naming convention. For each bridge it:
3939
*
4040
* 1. Derives the PHP namespace from the package's autoload configuration
41-
* 2. Checks for PlatformFactory and ModelCatalog classes
41+
* 2. Checks for Factory and ModelCatalog classes
4242
* 3. Reads models and per-model capabilities from the ModelCatalog
4343
* 4. Sanitizes model names for TCA compatibility (no colons)
4444
* 5. Detects the factory authentication parameter via reflection
@@ -195,7 +195,7 @@ private function resolveNamespace(string $packageName): ?string
195195
private function buildBridgeDefinition(array $package): ?array
196196
{
197197
$namespace = $package['namespace'];
198-
$factoryClass = $namespace . '\\PlatformFactory';
198+
$factoryClass = $namespace . '\\Factory';
199199

200200
if (!class_exists($factoryClass)) {
201201
return null;
@@ -397,15 +397,15 @@ private function deriveName(string $packageName): string
397397
}
398398

399399
/**
400-
* Detect the primary authentication parameter of a PlatformFactory::create() method.
400+
* Detect the primary authentication parameter of a Factory::createProvider() method.
401401
*
402402
* Most bridges use `apiKey`. Some (Ollama, LM Studio) use `endpoint`.
403403
* We check the first parameter name via reflection.
404404
*/
405405
private function detectFactoryParam(string $factoryClass): string
406406
{
407407
try {
408-
$method = new \ReflectionMethod($factoryClass, 'create');
408+
$method = new \ReflectionMethod($factoryClass, 'createProvider');
409409
foreach ($method->getParameters() as $param) {
410410
$name = $param->getName();
411411
if ($name === 'endpoint' || $name === 'hostUrl' || $name === 'baseUrl') {

Classes/Provider/SymfonyAi/SymfonyAiPlatformAdapter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
use Symfony\AI\Platform\Message\Content\Image;
3838
use Symfony\AI\Platform\Message\Message;
3939
use Symfony\AI\Platform\Message\MessageBag;
40-
use Symfony\AI\Platform\PlatformInterface;
40+
use Symfony\AI\Platform\ProviderInterface;
4141
use Symfony\AI\Platform\TokenUsage\TokenUsageInterface;
4242

4343
/**
@@ -61,13 +61,13 @@ class SymfonyAiPlatformAdapter implements
6161
ToolCallingCapableInterface,
6262
EmbeddingCapableInterface
6363
{
64-
/** @var array<string, PlatformInterface> Platforms cached by configuration key */
64+
/** @var array<string, ProviderInterface> Providers cached by configuration key */
6565
private array $platforms = [];
6666

6767
private readonly string $maxTokensKey;
6868

6969
/**
70-
* @param string $factoryClass Fully-qualified class name of the bridge's PlatformFactory
70+
* @param string $factoryClass Fully-qualified class name of the bridge's Factory
7171
* @param string $factoryParam Name of the factory parameter to pass the config value to ('apiKey' or 'endpoint')
7272
*/
7373
public function __construct(
@@ -237,16 +237,16 @@ public function processEmbeddingRequest(EmbeddingRequest $request): EmbeddingRes
237237
}
238238

239239
/**
240-
* Lazily create and cache a Platform instance per provider configuration.
240+
* Lazily create and cache a Provider instance per provider configuration.
241241
*/
242-
private function getPlatform(ProviderConfiguration $config): PlatformInterface
242+
private function getPlatform(ProviderConfiguration $config): ProviderInterface
243243
{
244244
$cacheKey = $config->uid > 0 ? (string)$config->uid : md5($config->apiKey . $config->model);
245245
if (!isset($this->platforms[$cacheKey])) {
246246
$factoryClass = $this->factoryClass;
247247
$this->platforms[$cacheKey] = match ($this->factoryParam) {
248-
'endpoint' => $factoryClass::create(endpoint: $config->apiKey),
249-
default => $factoryClass::create(apiKey: $config->apiKey),
248+
'endpoint' => $factoryClass::createProvider(endpoint: $config->apiKey),
249+
default => $factoryClass::createProvider(apiKey: $config->apiKey),
250250
};
251251
}
252252
return $this->platforms[$cacheKey];

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
"phpunit/phpunit": "^11.0",
1313
"typo3/testing-framework": "^9.0"
1414
},
15+
"conflict": {
16+
"symfony/ai-platform": "<0.8"
17+
},
1518
"suggest": {
16-
"symfony/ai-platform": "Required to use Symfony AI bridges as providers (OpenAI, Anthropic, Gemini, Mistral, Ollama, etc.)",
19+
"symfony/ai-platform": "^0.8 — required to use Symfony AI bridges as providers (OpenAI, Anthropic, Gemini, Mistral, Ollama, etc.)",
1720
"typo3/cms-dashboard": "Enables dashboard widgets for AI usage analytics"
1821
},
1922
"autoload": {

0 commit comments

Comments
 (0)