File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 15
15
'api_key ' => env ('OPENAI_API_KEY ' ),
16
16
'organization ' => env ('OPENAI_ORGANIZATION ' ),
17
17
18
+ /*
19
+ |--------------------------------------------------------------------------
20
+ | Request Timeout
21
+ |--------------------------------------------------------------------------
22
+ |
23
+ | The timeout may be used to specify the maximum number of seconds to wait
24
+ | for a response. By default, the client will time out after 30 seconds.
25
+ */
26
+
27
+ 'request_timeout ' => env ('OPENAI_REQUEST_TIMEOUT ' , 30 ),
18
28
];
Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ public function register(): void
29
29
throw ApiKeyIsMissing::create ();
30
30
}
31
31
32
- return OpenAI::client ($ apiKey , $ organization );
32
+ return OpenAI::factory ()
33
+ ->withApiKey ($ apiKey )
34
+ ->withOrganization ($ organization )
35
+ ->withHttpClient (new \GuzzleHttp \Client (['timeout ' => config ('openai.request_timeout ' , 30 )]))
36
+ ->make ();
33
37
});
34
38
35
39
$ this ->app ->alias (ClientContract::class, 'openai ' );
Original file line number Diff line number Diff line change 16
16
test ('service providers ' )
17
17
->expect ('OpenAI\Laravel\ServiceProvider ' )
18
18
->toOnlyUse ([
19
+ 'GuzzleHttp\Client ' ,
19
20
'Illuminate\Support\ServiceProvider ' ,
20
21
'OpenAI\Laravel ' ,
21
22
'OpenAI ' ,
You can’t perform that action at this time.
0 commit comments