diff --git a/composer.json b/composer.json index 4caa56a..f52b7c9 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", "laravel/framework": "^9.46.0|^10.34.2|^11.29.0", - "openai-php/client": "^0.10.2" + "openai-php/client": "^0.10.2", + "swisnl/laravel-psr-http-client-bridge": "^0.2.0" }, "require-dev": { "laravel/pint": "^1.18.1", diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index a6e6808..b41e050 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -5,6 +5,7 @@ namespace OpenAI\Laravel; use Illuminate\Contracts\Support\DeferrableProvider; +use Illuminate\Support\Facades\Http; use Illuminate\Support\ServiceProvider as BaseServiceProvider; use OpenAI; use OpenAI\Client; @@ -34,7 +35,8 @@ public function register(): void ->withApiKey($apiKey) ->withOrganization($organization) ->withHttpHeader('OpenAI-Beta', 'assistants=v2') - ->withHttpClient(new \GuzzleHttp\Client(['timeout' => config('openai.request_timeout', 30)])) + ->withHttpClient(new \Swis\Laravel\Bridge\PsrHttpClient\Client( + fn () => Http::timeout((int) config('openai.request_timeout', 30)))) ->make(); });