Skip to content

Commit 0ec4ba0

Browse files
Merge pull request #293 from eliashaeussler/fix/list-supported-models
[BUGFIX] List only supported models in `solver:list-models` command
2 parents 15a1dd0 + 62fe254 commit 0ec4ba0

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

Classes/Command/ListModelsCommand.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
6565
$io->title('Available GPT models');
6666

6767
// Filter by GPT models
68-
$modelListResponse = \array_filter($modelListResponse, $this->isGPTModel(...));
68+
$modelListResponse = \array_filter($modelListResponse, $this->isSupportedModel(...));
6969
}
7070

7171
// Map responses to model IDs
@@ -86,9 +86,18 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
8686
return self::SUCCESS;
8787
}
8888

89-
private function isGPTModel(Responses\Models\RetrieveResponse $response): bool
89+
/**
90+
* @see https://platform.openai.com/docs/models#model-endpoint-compatibility
91+
*/
92+
private function isSupportedModel(Responses\Models\RetrieveResponse $response): bool
9093
{
91-
return \str_starts_with(\strtolower($response->id), 'gpt-');
94+
$identifier = \strtolower($response->id);
95+
96+
if (!\str_starts_with($identifier, 'gpt-') && !\str_starts_with($identifier, 'chatgpt-')) {
97+
return false;
98+
}
99+
100+
return !\str_contains($identifier, '-realtime') && !\str_contains($identifier, '-audio');
92101
}
93102

94103
private function decorateModel(Responses\Models\RetrieveResponse $response): string

Resources/Private/Frontend/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/Unit/Command/ListModelsCommandTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp(): void
6363
}
6464

6565
#[Framework\Attributes\Test]
66-
public function executeListsAllGPTModels(): void
66+
public function executeListsAllSupportedModels(): void
6767
{
6868
$response = new Psr7\Response(headers: [
6969
'Content-Type' => 'application/json',
@@ -88,6 +88,13 @@ public function executeListsAllGPTModels(): void
8888
]),
8989
$this->commandTester->getDisplay(),
9090
);
91+
self::assertStringNotContainsString(
92+
\implode(PHP_EOL, [
93+
' * gpt-4o-mini-audio-preview (created at 16/12/2024)',
94+
' * gpt-4o-realtime-preview (created at 30/09/2024)',
95+
]),
96+
$this->commandTester->getDisplay(),
97+
);
9198
self::assertStringContainsString(
9299
\implode(PHP_EOL, [
93100
' * gpt-3.5 (created at 28/02/2023)',
@@ -124,6 +131,8 @@ public function executeListsAllAvailableModels(): void
124131
' * foo-1 (created at 01/01/2023)',
125132
' * gpt-3.5 (created at 28/02/2023)',
126133
' * gpt-3.5-turbo-0301 (created at 01/03/2023)',
134+
' * gpt-4o-mini-audio-preview (created at 16/12/2024)',
135+
' * gpt-4o-realtime-preview (created at 30/09/2024)',
127136
]),
128137
$this->commandTester->getDisplay(),
129138
);
@@ -188,6 +197,18 @@ private function createListResponse(): array
188197
'created' => 1641038400,
189198
...$defaults,
190199
],
200+
[
201+
'id' => 'gpt-4o-realtime-preview',
202+
// 30/09/2024
203+
'created' => 1727654400,
204+
...$defaults,
205+
],
206+
[
207+
'id' => 'gpt-4o-mini-audio-preview',
208+
// 16/12/2024
209+
'created' => 1734307200,
210+
...$defaults,
211+
],
191212
],
192213
];
193214
}

0 commit comments

Comments
 (0)