Movatterモバイル変換


[0]ホーム

URL:


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

Commitac29660

Browse files
authored
Add an alias for the ClientContract (openai-php#22)
1 parent8e33983 commitac29660

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
useOpenAI;
88
useOpenAI\Client;
9+
useOpenAI\Contracts\ClientContract;
910
useOpenAI\Factory;
1011
useSymfony\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
namespaceOpenAI\Symfony\Tests\DependencyInjection;
66

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

1415
finalclass OpenAIExtensionTestextends TestCase
1516
{
16-
publicfunctiontestService():void
17+
publicfunctiontest_service():void
1718
{
1819
// Using a mock to test the service configuration
1920
$httpClient =newMockHttpClient(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)

[8]ページ先頭

©2009-2025 Movatter.jp