Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 01542ed

Browse files
committed
-
1 parent 4c8003c commit 01542ed

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/Platform/Bridge/Albert/EmbeddingsModelClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function request(Model $model, array|string $payload, array $options = []
3636
{
3737
return $this->httpClient->request('POST', rtrim($this->baseUrl, '/').'/embeddings', [
3838
'auth_bearer' => $this->apiKey,
39-
'json' => is_array($payload) ? array_merge($payload, $options) : $payload,
39+
'json' => \is_array($payload) ? array_merge($payload, $options) : $payload,
4040
]);
4141
}
4242
}

src/Platform/Bridge/Albert/GPTModelClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function request(Model $model, array|string $payload, array $options = []
4040
{
4141
return $this->httpClient->request('POST', rtrim($this->baseUrl, '/').'/chat/completions', [
4242
'auth_bearer' => $this->apiKey,
43-
'json' => is_array($payload) ? array_merge($payload, $options) : $payload,
43+
'json' => \is_array($payload) ? array_merge($payload, $options) : $payload,
4444
]);
4545
}
4646
}

tests/Platform/Bridge/Albert/EmbeddingsModelClientTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function requestSendsCorrectHttpRequest(array|string $payload, array $opt
7979
$capturedRequest = null;
8080
$httpClient = new MockHttpClient(function ($method, $url, $options) use (&$capturedRequest) {
8181
$capturedRequest = ['method' => $method, 'url' => $url, 'options' => $options];
82+
8283
return new JsonMockResponse(['data' => []]);
8384
});
8485

@@ -97,7 +98,7 @@ public function requestSendsCorrectHttpRequest(array|string $payload, array $opt
9798
self::assertArrayHasKey('normalized_headers', $capturedRequest['options']);
9899
self::assertArrayHasKey('authorization', $capturedRequest['options']['normalized_headers']);
99100
self::assertStringContainsString('Bearer test-api-key', $capturedRequest['options']['normalized_headers']['authorization'][0]);
100-
101+
101102
// Check JSON body - it might be in 'body' after processing
102103
if (isset($capturedRequest['options']['body'])) {
103104
$actualJson = json_decode($capturedRequest['options']['body'], true);
@@ -140,6 +141,7 @@ public function requestHandlesBaseUrlWithoutTrailingSlash(): void
140141
$capturedUrl = null;
141142
$httpClient = new MockHttpClient(function ($method, $url) use (&$capturedUrl) {
142143
$capturedUrl = $url;
144+
143145
return new JsonMockResponse(['data' => []]);
144146
});
145147

@@ -161,6 +163,7 @@ public function requestHandlesBaseUrlWithTrailingSlash(): void
161163
$capturedUrl = null;
162164
$httpClient = new MockHttpClient(function ($method, $url) use (&$capturedUrl) {
163165
$capturedUrl = $url;
166+
164167
return new JsonMockResponse(['data' => []]);
165168
});
166169

@@ -175,4 +178,4 @@ public function requestHandlesBaseUrlWithTrailingSlash(): void
175178

176179
self::assertSame('https://albert.example.com/v1/embeddings', $capturedUrl);
177180
}
178-
}
181+
}

tests/Platform/Bridge/Albert/GPTModelClientTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function constructorThrowsExceptionForEmptyBaseUrl(): void
5151
public function constructorWrapsHttpClientInEventSourceHttpClient(): void
5252
{
5353
$mockHttpClient = new MockHttpClient();
54-
54+
5555
$client = new GPTModelClient(
5656
$mockHttpClient,
5757
'test-api-key',
@@ -74,7 +74,7 @@ public function constructorAcceptsEventSourceHttpClient(): void
7474
{
7575
$mockHttpClient = new MockHttpClient();
7676
$eventSourceClient = new EventSourceHttpClient($mockHttpClient);
77-
77+
7878
$client = new GPTModelClient(
7979
$eventSourceClient,
8080
'test-api-key',
@@ -124,6 +124,7 @@ public function requestSendsCorrectHttpRequest(array|string $payload, array $opt
124124
$capturedRequest = null;
125125
$httpClient = new MockHttpClient(function ($method, $url, $options) use (&$capturedRequest) {
126126
$capturedRequest = ['method' => $method, 'url' => $url, 'options' => $options];
127+
127128
return new JsonMockResponse(['choices' => []]);
128129
});
129130

@@ -142,7 +143,7 @@ public function requestSendsCorrectHttpRequest(array|string $payload, array $opt
142143
self::assertArrayHasKey('normalized_headers', $capturedRequest['options']);
143144
self::assertArrayHasKey('authorization', $capturedRequest['options']['normalized_headers']);
144145
self::assertStringContainsString('Bearer test-api-key', $capturedRequest['options']['normalized_headers']['authorization'][0]);
145-
146+
146147
// Check JSON body - it might be in 'body' after processing
147148
if (isset($capturedRequest['options']['body'])) {
148149
$actualJson = json_decode($capturedRequest['options']['body'], true);
@@ -191,6 +192,7 @@ public function requestHandlesBaseUrlWithoutTrailingSlash(): void
191192
$capturedUrl = null;
192193
$httpClient = new MockHttpClient(function ($method, $url) use (&$capturedUrl) {
193194
$capturedUrl = $url;
195+
194196
return new JsonMockResponse(['choices' => []]);
195197
});
196198

@@ -212,6 +214,7 @@ public function requestHandlesBaseUrlWithTrailingSlash(): void
212214
$capturedUrl = null;
213215
$httpClient = new MockHttpClient(function ($method, $url) use (&$capturedUrl) {
214216
$capturedUrl = $url;
217+
215218
return new JsonMockResponse(['choices' => []]);
216219
});
217220

@@ -226,4 +229,4 @@ public function requestHandlesBaseUrlWithTrailingSlash(): void
226229

227230
self::assertSame('https://albert.example.com/v1/chat/completions', $capturedUrl);
228231
}
229-
}
232+
}

0 commit comments

Comments
 (0)