Skip to content

Commit 39e4538

Browse files
committed
Remove perplexity case and make default throw exception
- Remove specific perplexity case from createModelForPlatform method - Change default case to throw InvalidArgumentException with platform name - Update test to use generic unsupported platform instead of perplexity - Provides better error messages for unsupported platforms
1 parent 5f9dc4a commit 39e4538

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/ai-bundle/src/Command/PlatformInvokeCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ private function createModelForPlatform(string $platformName, string $modelName)
156156
'google' => new \Symfony\AI\Platform\Bridge\Gemini\Gemini($modelName),
157157
'ollama' => new \Symfony\AI\Platform\Bridge\Ollama\Ollama($modelName),
158158
'mistral' => new \Symfony\AI\Platform\Bridge\Mistral\Mistral($modelName),
159-
'perplexity' => throw new InvalidArgumentException('Perplexity platform is not yet supported in ai:platform:invoke command'),
160-
default => new Model($modelName), // Fallback to generic model
159+
default => throw new InvalidArgumentException(\sprintf('Platform "%s" is not supported in ai:platform:invoke command', $platformName)),
161160
};
162161
}
163162
}

src/ai-bundle/tests/Command/PlatformInvokeCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,23 @@ public function testExecuteWithWhitespaceOnlyModel()
182182
]);
183183
}
184184

185-
public function testExecuteWithPerplexityPlatformThrowsException()
185+
public function testExecuteWithUnsupportedPlatformThrowsException()
186186
{
187187
$platforms = $this->createMock(ServiceLocator::class);
188188
$mockPlatform = $this->createMock(PlatformInterface::class);
189-
$platforms->method('getProvidedServices')->willReturn(['perplexity' => 'service_class']);
190-
$platforms->method('has')->with('perplexity')->willReturn(true);
191-
$platforms->method('get')->with('perplexity')->willReturn($mockPlatform);
189+
$platforms->method('getProvidedServices')->willReturn(['unsupported' => 'service_class']);
190+
$platforms->method('has')->with('unsupported')->willReturn(true);
191+
$platforms->method('get')->with('unsupported')->willReturn($mockPlatform);
192192

193193
$command = new PlatformInvokeCommand($platforms);
194194

195195
$this->expectException(InvalidArgumentException::class);
196-
$this->expectExceptionMessage('Perplexity platform is not yet supported in ai:platform:invoke command');
196+
$this->expectExceptionMessage('Platform "unsupported" is not supported in ai:platform:invoke command');
197197

198198
$commandTester = new CommandTester($command);
199199
$commandTester->execute([
200-
'platform' => 'perplexity',
201-
'model' => 'sonar',
200+
'platform' => 'unsupported',
201+
'model' => 'some-model',
202202
'message' => 'Test message',
203203
]);
204204
}

0 commit comments

Comments
 (0)