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

Sign up
Appearance settings

Commit ac29660

Browse files
authored
Add an alias for the ClientContract (openai-php#22)
1 parent 8e33983 commit ac29660

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

‎src/Resources/config/services.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use OpenAI;
88
use OpenAI\Client;
9+
use OpenAI\Contracts\ClientContract;
910
use OpenAI\Factory;
1011
use Symfony\Component\HttpClient\Psr18Client;
1112

@@ -22,5 +23,6 @@
2223
->set(Client::class)
2324
->factory([service(Factory::class), 'make'])
2425

26+
->alias(ClientContract::class, Client::class)
2527
->alias('openai', Client::class);
2628
};

‎tests/DependencyInjection/OpenAIExtensionTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace OpenAI\Symfony\Tests\DependencyInjection;
66

77
use OpenAI\Client;
8+
use OpenAI\Contracts\ClientContract;
89
use OpenAI\Symfony\DependencyInjection\OpenAIExtension;
910
use PHPUnit\Framework\TestCase;
1011
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -13,7 +14,7 @@
1314

1415
final class OpenAIExtensionTest extends TestCase
1516
{
16-
public function testService(): void
17+
public function test_service(): void
1718
{
1819
// Using a mock to test the service configuration
1920
$httpClient = new MockHttpClient(function (string $method, string $url, array $options = []) {
@@ -45,5 +46,7 @@ public function testService(): void
4546

4647
$response = $openai->files()->delete('file.txt');
4748
self::assertSame('file.txt', $response->id);
49+
50+
self::assertSame($openai, $container->get(ClientContract::class), 'Alias for the ClientContract interface');
4851
}
4952
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /