File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Open diff view settings
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Open diff view settings
Original file line number Diff line number Diff line change 88use Illuminate \Support \ServiceProvider as BaseServiceProvider ;
99use OpenAI ;
1010use OpenAI \Client ;
11+ use OpenAI \Contracts \ClientContract ;
1112use OpenAI \Laravel \Exceptions \ApiKeyIsMissing ;
1213
1314/**
@@ -20,7 +21,7 @@ final class ServiceProvider extends BaseServiceProvider implements DeferrablePro
2021 */
2122 public function register (): void
2223 {
23- $ this ->app ->singleton (Client ::class, static function (): Client {
24+ $ this ->app ->singleton (ClientContract ::class, static function (): Client {
2425 $ apiKey = config ('openai.api_key ' );
2526 $ organization = config ('openai.organization ' );
2627
@@ -31,7 +32,8 @@ public function register(): void
3132 return OpenAI::client ($ apiKey , $ organization );
3233 });
3334
34- $ this ->app ->alias (Client::class, 'openai ' );
35+ $ this ->app ->alias (ClientContract::class, 'openai ' );
36+ $ this ->app ->alias (ClientContract::class, Client::class);
3537 }
3638
3739 /**
@@ -55,6 +57,8 @@ public function provides(): array
5557 {
5658 return [
5759 Client::class,
60+ ClientContract::class,
61+ 'openai ' ,
5862 ];
5963 }
6064}
You can’t perform that action at this time.
0 commit comments