Skip to content

Commit 2ff975f

Browse files
OskarStarkclaude
andcommitted
Update OpenAI examples to use string model names instead of Model objects
Updated examples: - chat.php: Use 'gpt-4o-mini' string instead of new Gpt() object - embeddings.php: Use 'text-embedding-3-small' instead of new Embeddings() object - audio-transcript.php: Use 'whisper-1' instead of new Whisper() object - image-output-dall-e-2.php: Use 'dall-e-2' string - image-output-dall-e-3.php: Use 'dall-e-3' string - additional-model.php: Already updated in previous commit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5a55186 commit 2ff975f

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

examples/openai/additional-model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
),
4545
);
4646

47-
$result = $platform->invoke($modelCatalog->getModel('gpt-4o-mini-transcribe'), $messages);
47+
$result = $platform->invoke('gpt-4o-mini-transcribe', $messages);
4848

4949
echo $result->getResult()->getContent().\PHP_EOL;

examples/openai/audio-transcript.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
require_once dirname(__DIR__).'/bootstrap.php';
1717

1818
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
19-
$model = new Whisper(Whisper::WHISPER_1);
2019
$file = Audio::fromFile(dirname(__DIR__, 2).'/fixtures/audio.mp3');
2120

22-
$result = $platform->invoke($model, $file);
21+
$result = $platform->invoke('whisper-1', $file);
2322

2423
echo $result->asText().\PHP_EOL;

examples/openai/chat.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
require_once dirname(__DIR__).'/bootstrap.php';
1818

1919
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
20-
$model = new Gpt(Gpt::GPT_4O_MINI);
2120

2221
$messages = new MessageBag(
2322
Message::forSystem('You are a pirate and you write funny.'),
2423
Message::ofUser('What is the Symfony framework?'),
2524
);
26-
$result = $platform->invoke($model, $messages, [
25+
$result = $platform->invoke('gpt-4o-mini', $messages, [
2726
'max_tokens' => 500, // specific options just for this call
2827
]);
2928

examples/openai/embeddings.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
require_once dirname(__DIR__).'/bootstrap.php';
1616

1717
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
18-
$embeddings = new Embeddings(Embeddings::TEXT_3_SMALL);
1918

20-
$result = $platform->invoke($embeddings, <<<TEXT
19+
$result = $platform->invoke('text-embedding-3-small', <<<TEXT
2120
Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.
2221
The people of Japan were very kind and hardworking. They loved their country very much and took care of it. The
2322
country was very peaceful and prosperous. The people lived happily ever after.

examples/openai/image-output-dall-e-2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
1818

1919
$result = $platform->invoke(
20-
model: new DallE(DallE::DALL_E_2),
20+
model: 'dall-e-2',
2121
input: 'A cartoon-style elephant with a long trunk and large ears.',
2222
options: [
2323
'response_format' => 'url', // Generate response as URL

examples/openai/image-output-dall-e-3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
1919

2020
$result = $platform->invoke(
21-
model: new DallE(name: DallE::DALL_E_3),
21+
model: 'dall-e-3',
2222
input: 'A cartoon-style elephant with a long trunk and large ears.',
2323
options: [
2424
'response_format' => 'url', // Generate response as URL

0 commit comments

Comments
 (0)