Skip to content

Commit 844f205

Browse files
VincentLangletOskarStark
authored andcommitted
[AI Bundle][Platform] Fix Anthropic platform definition
1 parent 1f39a86 commit 844f205

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
@@ -174,16 +174,12 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
174174
->setLazy(true)
175175
->addTag('proxy', ['interface' => PlatformInterface::class])
176176
->setArguments([
177-
0 => $platform['api_key'],
178-
2 => new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
179-
3 => new Reference('ai.platform.contract.anthropic'),
177+
$platform['api_key'],
178+
new Reference('http_client', ContainerInterface::NULL_ON_INVALID_REFERENCE),
179+
new Reference('ai.platform.contract.anthropic'),
180180
])
181181
->addTag('ai.platform');
182182

183-
if (isset($platform['version'])) {
184-
$definition->setArgument(1, $platform['version']);
185-
}
186-
187183
$container->setDefinition($platformId, $definition);
188184

189185
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)