File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 3
3
namespace HalilCosdu \FineTuner ;
4
4
5
5
use HalilCosdu \FineTuner \Commands \FineTunerCommand ;
6
+ use InvalidArgumentException ;
6
7
use OpenAI ;
7
8
use Spatie \LaravelPackageTools \Package ;
8
9
use Spatie \LaravelPackageTools \PackageServiceProvider ;
@@ -25,11 +26,21 @@ public function configurePackage(Package $package): void
25
26
public function packageRegistered (): void
26
27
{
27
28
$ this ->app ->singleton (FineTuner::class, function ($ app ) {
29
+ $ apiKey = config ('finetuner.api_key ' );
30
+ $ organization = config ('finetuner.organization ' );
31
+ $ timeout = config ('finetuner.request_timeout ' , 30 );
32
+
33
+ if (! is_string ($ apiKey ) || ($ organization !== null && ! is_string ($ organization ))) {
34
+ throw new InvalidArgumentException (
35
+ 'The OpenAI API Key is missing. Please publish the [finetuner.php] configuration file and set the [api_key]. '
36
+ );
37
+ }
38
+
28
39
return new FineTuner (
29
40
OpenAI::factory ()
30
- ->withApiKey (config ( ' finetuner.api_key ' ) )
31
- ->withOrganization (config ( ' finetuner. organization' ) )
32
- ->withHttpClient (new \GuzzleHttp \Client (['timeout ' => config ( ' finetuner.request_timeout ' , 600 ) ]))
41
+ ->withApiKey ($ apiKey )
42
+ ->withOrganization ($ organization )
43
+ ->withHttpClient (new \GuzzleHttp \Client (['timeout ' => $ timeout ]))
33
44
->make ()
34
45
);
35
46
});
You can’t perform that action at this time.
0 commit comments