Skip to content

Commit 70bc6b5

Browse files
committed
bug #369 [AI Bundle][Platform] Fix Anthropic platform definition (VincentLanglet)
This PR was squashed before being merged into the main branch. Discussion ---------- [AI Bundle][Platform] Fix Anthropic platform definition | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no <!-- required for new features --> | Issues | Fix #363 | License | MIT Commits ------- 844f205 [AI Bundle][Platform] Fix Anthropic platform definition
2 parents 698d71b + 844f205 commit 70bc6b5

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/ai-bundle/src/AiBundle.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,12 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
178178
->setLazy(true)
179179
->addTag('proxy', ['interface' => PlatformInterface::class])
180180
->setArguments([
181-
0 => $platform['api_key'],
182-
2 => new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
183-
3 => new Reference('ai.platform.contract.anthropic'),
181+
$platform['api_key'],
182+
new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
183+
new Reference('ai.platform.contract.anthropic'),
184184
])
185185
->addTag('ai.platform');
186186

187-
if (isset($platform['version'])) {
188-
$definition->setArgument(1, $platform['version']);
189-
}
190-
191187
$container->setDefinition($platformId, $definition);
192188

193189
return;

src/platform/src/Bridge/Anthropic/ModelClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
public function __construct(
2828
HttpClientInterface $httpClient,
2929
#[\SensitiveParameter] private string $apiKey,
30-
private string $version = '2023-06-01',
3130
) {
3231
$this->httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient);
3332
}
@@ -41,7 +40,7 @@ public function request(Model $model, array|string $payload, array $options = []
4140
{
4241
$headers = [
4342
'x-api-key' => $this->apiKey,
44-
'anthropic-version' => $this->version,
43+
'anthropic-version' => '2023-06-01',
4544
];
4645

4746
if (isset($options['tools'])) {

src/platform/src/Bridge/Anthropic/PlatformFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
public static function create(
2626
#[\SensitiveParameter]
2727
string $apiKey,
28-
string $version = '2023-06-01',
2928
?HttpClientInterface $httpClient = null,
3029
?Contract $contract = null,
3130
): Platform {
3231
$httpClient = $httpClient instanceof EventSourceHttpClient ? $httpClient : new EventSourceHttpClient($httpClient);
3332

3433
return new Platform(
35-
[new ModelClient($httpClient, $apiKey, $version)],
34+
[new ModelClient($httpClient, $apiKey)],
3635
[new ResultConverter()],
3736
$contract ?? AnthropicContract::create(),
3837
);

src/platform/tests/Bridge/Anthropic/ModelClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testAnthropicBetaHeaderIsSetWithMultipleBetaFeatures()
6161
return new JsonMockResponse('{"success": true}');
6262
});
6363

64-
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key', '2023-06-01');
64+
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key');
6565

6666
$options = ['beta_features' => ['feature-1', 'feature-2', 'feature-3']];
6767
$this->modelClient->request($this->model, ['message' => 'test'], $options);
@@ -77,7 +77,7 @@ public function testAnthropicBetaHeaderIsNotSetWhenBetaFeaturesIsEmpty()
7777
return new JsonMockResponse('{"success": true}');
7878
});
7979

80-
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key', '2023-06-01');
80+
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key');
8181

8282
$options = ['beta_features' => []];
8383
$this->modelClient->request($this->model, ['message' => 'test'], $options);
@@ -93,7 +93,7 @@ public function testAnthropicBetaHeaderIsNotSetWhenBetaFeaturesIsNotProvided()
9393
return new JsonMockResponse('{"success": true}');
9494
});
9595

96-
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key', '2023-06-01');
96+
$this->modelClient = new ModelClient($this->httpClient, 'test-api-key');
9797

9898
$options = ['some_other_option' => 'value'];
9999
$this->modelClient->request($this->model, ['message' => 'test'], $options);

0 commit comments

Comments
 (0)