diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index ab7c16a..50b36af 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Cache dependencies uses: actions/cache@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7ab8996..4937678 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Cache dependencies uses: actions/cache@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 37da658..687f8b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.16.0 (2025-08-26) +### Changed + - Changed underlying `openai/client` package version from 0.15.0 to 0.16.0 + - HTTP 429 now throw a `RateLimitException` instead of a generic `ErrorException` + +## v0.15.0 (2025-08-04) +### Added +- Add facade for `containers`. ([#161](https://github.com/openai-php/laravel/pull/161)) + +### Changed +- Changed underlying `openai/client` package version from 0.14.0 to 0.15.0 + ## v0.14.0 (2025-06-24) ### Added - Add facade for `realtime`. ([#156](https://github.com/openai-php/laravel/pull/156)) diff --git a/README.md b/README.md index f68de3e..d452d93 100644 --- a/README.md +++ b/README.md @@ -46,14 +46,12 @@ Finally, you may use the `OpenAI` facade to access the OpenAI API: ```php use OpenAI\Laravel\Facades\OpenAI; -$result = OpenAI::chat()->create([ - 'model' => 'gpt-4o-mini', - 'messages' => [ - ['role' => 'user', 'content' => 'Hello!'], - ], +$response = OpenAI::responses()->create([ + 'model' => 'gpt-5', + 'input' => 'Hello!', ]); -echo $result->choices[0]->message->content; // Hello! How can I assist you today? +echo $response->outputText; // Hello! How can I assist you today? ``` ## Configuration @@ -111,7 +109,7 @@ All responses are having a `fake()` method that allows you to easily create a re ```php use OpenAI\Laravel\Facades\OpenAI; -use OpenAI\Responses\Completions\CreateResponse; +use OpenAI\Responses\Responses\CreateResponse; OpenAI::fake([ CreateResponse::fake([ @@ -123,21 +121,21 @@ OpenAI::fake([ ]), ]); -$completion = OpenAI::completions()->create([ - 'model' => 'gpt-4o-mini', - 'prompt' => 'PHP is ', +$response = OpenAI::responses()->create([ + 'model' => 'gpt-5', + 'input' => 'PHP is ', ]); -expect($completion['choices'][0]['text'])->toBe('awesome!'); +expect($response->outputText)->toBe('awesome!'); ``` After the requests have been sent there are various methods to ensure that the expected requests were sent: ```php // assert completion create request was sent -OpenAI::assertSent(Completions::class, function (string $method, array $parameters): bool { +OpenAI::assertSent(Responses::class, function (string $method, array $parameters): bool { return $method === 'create' && - $parameters['model'] === 'gpt-4o-mini' && + $parameters['model'] === 'gpt-5' && $parameters['prompt'] === 'PHP is '; }); ``` diff --git a/composer.json b/composer.json index 60cd36b..40ba5ce 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.14.0" + "openai-php/client": "^0.16.1" }, "require-dev": { "laravel/pint": "^1.22.0", "pestphp/pest": "^3.8.2|^4.0.0", "pestphp/pest-plugin-arch": "^3.1.1|^4.0.0", - "phpstan/phpstan": "^1.12.25", + "phpstan/phpstan": "^2.1", "symfony/var-dumper": "^7.2.6" }, "autoload": { diff --git a/src/Facades/OpenAI.php b/src/Facades/OpenAI.php index 09f6aaf..cdc2921 100644 --- a/src/Facades/OpenAI.php +++ b/src/Facades/OpenAI.php @@ -15,6 +15,7 @@ * @method static \OpenAI\Resources\Batches batches() * @method static \OpenAI\Resources\Chat chat() * @method static \OpenAI\Resources\Completions completions() + * @method static \OpenAI\Resources\Containers containers() * @method static \OpenAI\Resources\Embeddings embeddings() * @method static \OpenAI\Resources\Edits edits() * @method static \OpenAI\Resources\Files files()