Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 373a1f5

Browse filesBrowse files
committed
Merge branch 'main' of github.com:openai-php/laravel
2 parents c2d5e24 + 8d6d3cb commit 373a1f5
Copy full SHA for 373a1f5

File tree

Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Collapse file

‎src/ServiceProvider.php‎

Copy file name to clipboardExpand all lines: src/ServiceProvider.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
99
use OpenAI;
1010
use OpenAI\Client;
11+
use OpenAI\Contracts\ClientContract;
1112
use 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
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.