Skip to content

Commit 3f75f6b

Browse files
victor-upmeetVictor Thuillier
andauthored
Create BedrockRuntime client with InvokeModel operation (#1849)
* Create BedrockRuntime client with InvokeModel operation * Fix documentation URL * Fix BedrockRuntime InvokeModel documentation example * Regenrate BedrockRuntime InvokeModel * Input and Result unit tests for BedrockRuntime InvokeModel operation * Fix BedrockRuntime tests * Fix BedrockRuntime tests * Fix SymfonyBundle Changelog * Upgraded Symfony/Bundle branch-alias dev-master from 1.13-dev to 1.14-dev * Removed .idea files * Remove BedrockRuntime service endpoint- and smoke properties --------- Co-authored-by: Victor Thuillier <[email protected]>
1 parent e8da451 commit 3f75f6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1125
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See full documentation on [https://async-aws.com](https://async-aws.com).
1313
| [async-aws/core](https://github.com/async-aws/core) | [![Latest Stable Version](https://poser.pugx.org/async-aws/core/v/stable)](https://packagist.org/packages/async-aws/core) [![Total Downloads](https://poser.pugx.org/async-aws/core/downloads)](https://packagist.org/packages/async-aws/core) | [![](https://github.com/async-aws/core/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/core/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/core.svg)](https://github.com/async-aws/core/releases) |
1414
| [async-aws/app-sync](https://github.com/async-aws/app-sync) | [![Latest Stable Version](https://poser.pugx.org/async-aws/app-sync/v/stable)](https://packagist.org/packages/async-aws/app-sync) [![Total Downloads](https://poser.pugx.org/async-aws/app-sync/downloads)](https://packagist.org/packages/async-aws/app-sync) | [![](https://github.com/async-aws/app-sync/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/app-sync/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/app-sync.svg)](https://github.com/async-aws/app-sync/releases) |
1515
| [async-aws/athena](https://github.com/async-aws/athena) | [![Latest Stable Version](https://poser.pugx.org/async-aws/athena/v/stable)](https://packagist.org/packages/async-aws/athena) [![Total Downloads](https://poser.pugx.org/async-aws/athena/downloads)](https://packagist.org/packages/async-aws/athena) | [![](https://github.com/async-aws/athena/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/athena/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/athena.svg)](https://github.com/async-aws/athena/releases) |
16+
| [async-aws/bedrock-runtime](https://github.com/async-aws/bedrock-runtime) | [![Latest Stable Version](https://poser.pugx.org/async-aws/bedrock-runtime/v/stable)](https://packagist.org/packages/async-aws/bedrock-runtime) [![Total Downloads](https://poser.pugx.org/async-aws/bedrock-runtime/downloads)](https://packagist.org/packages/async-aws/bedrock-runtime) | [![](https://github.com/async-aws/bedrock-runtime/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/bedrock-runtime/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/bedrock-runtime.svg)](https://github.com/async-aws/bedrock-runtime/releases) |
1617
| [async-aws/cloud-formation](https://github.com/async-aws/cloud-formation) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-formation/v/stable)](https://packagist.org/packages/async-aws/cloud-formation) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-formation/downloads)](https://packagist.org/packages/async-aws/cloud-formation) | [![](https://github.com/async-aws/cloud-formation/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-formation/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-formation.svg)](https://github.com/async-aws/cloud-formation/releases) |
1718
| [async-aws/cloud-front](https://github.com/async-aws/cloud-front) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-front/v/stable)](https://packagist.org/packages/async-aws/cloud-front) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-front/downloads)](https://packagist.org/packages/async-aws/cloud-front) | [![](https://github.com/async-aws/cloud-front/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-front/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-front.svg)](https://github.com/async-aws/cloud-front/releases) |
1819
| [async-aws/cloud-watch](https://github.com/async-aws/cloud-watch) | [![Latest Stable Version](https://poser.pugx.org/async-aws/cloud-watch/v/stable)](https://packagist.org/packages/async-aws/cloud-watch) [![Total Downloads](https://poser.pugx.org/async-aws/cloud-watch/downloads)](https://packagist.org/packages/async-aws/cloud-watch) | [![](https://github.com/async-aws/cloud-watch/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/cloud-watch/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-watch.svg)](https://github.com/async-aws/cloud-watch/releases) |
@@ -46,7 +47,7 @@ See full documentation on [https://async-aws.com](https://async-aws.com).
4647
| [async-aws/sqs](https://github.com/async-aws/sqs) | [![Latest Stable Version](https://poser.pugx.org/async-aws/sqs/v/stable)](https://packagist.org/packages/async-aws/sqs) [![Total Downloads](https://poser.pugx.org/async-aws/sqs/downloads)](https://packagist.org/packages/async-aws/sqs) | [![](https://github.com/async-aws/sqs/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/sqs/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/sqs.svg)](https://github.com/async-aws/sqs/releases) |
4748
| [async-aws/ssm](https://github.com/async-aws/ssm) | [![Latest Stable Version](https://poser.pugx.org/async-aws/ssm/v/stable)](https://packagist.org/packages/async-aws/ssm) [![Total Downloads](https://poser.pugx.org/async-aws/ssm/downloads)](https://packagist.org/packages/async-aws/ssm) | [![](https://github.com/async-aws/ssm/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/ssm/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/ssm.svg)](https://github.com/async-aws/ssm/releases) |
4849
| [async-aws/sso](https://github.com/async-aws/sso) | [![Latest Stable Version](https://poser.pugx.org/async-aws/sso/v/stable)](https://packagist.org/packages/async-aws/sso) [![Total Downloads](https://poser.pugx.org/async-aws/sso/downloads)](https://packagist.org/packages/async-aws/sso) | [![](https://github.com/async-aws/sso/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/sso/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/sso.svg)](https://github.com/async-aws/sso/releases) |
49-
| [async-aws/sso-oidc](https://github.com/async-aws/sso-oidc) | [![Latest Stable Version](https://poser.pugx.org/async-aws/sso-oidc/v/stable)](https://packagist.org/packages/async-aws/sso-oidc) [![Total Downloads](https://poser.pugx.org/async-aws/sso-oidc/downloads)](https://packagist.org/packages/async-aws/sso-oidc) | [![](https://github.com/async-aws/sso-oidc/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/sso-oidc/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/sso-oidc.svg)](https://github.com/async-aws/sso-oidc/releases) |
50+
| [async-aws/sso-oidc](https://github.com/async-aws/sso-oidc) | [![Latest Stable Version](https://poser.pugx.org/async-aws/sso-oidc/v/stable)](https://packagist.org/packages/async-aws/sso-oidc) [![Total Downloads](https://poser.pugx.org/async-aws/sso-oidc/downloads)](https://packagist.org/packages/async-aws/sso-oidc) | [![](https://github.com/async-aws/sso-oidc/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/sso-oidc/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/sso-oidc.svg)](https://github.com/async-aws/sso-oidc/releases) |
5051
| [async-aws/step-functions](https://github.com/async-aws/step-functions) | [![Latest Stable Version](https://poser.pugx.org/async-aws/step-functions/v/stable)](https://packagist.org/packages/async-aws/step-functions) [![Total Downloads](https://poser.pugx.org/async-aws/step-functions/downloads)](https://packagist.org/packages/async-aws/step-functions) | [![](https://github.com/async-aws/step-functions/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/step-functions/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/step-functions.svg)](https://github.com/async-aws/step-functions/releases) |
5152
| [async-aws/timestream-query](https://github.com/async-aws/timestream-query) | [![Latest Stable Version](https://poser.pugx.org/async-aws/timestream-query/v/stable)](https://packagist.org/packages/async-aws/timestream-query) [![Total Downloads](https://poser.pugx.org/async-aws/timestream-query/downloads)](https://packagist.org/packages/async-aws/timestream-query) | [![](https://github.com/async-aws/timestream-query/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/timestream-query/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/timestream-query.svg)](https://github.com/async-aws/timestream-query/releases) |
5253
| [async-aws/timestream-write](https://github.com/async-aws/timestream-write) | [![Latest Stable Version](https://poser.pugx.org/async-aws/timestream-write/v/stable)](https://packagist.org/packages/async-aws/timestream-write) [![Total Downloads](https://poser.pugx.org/async-aws/timestream-write/downloads)](https://packagist.org/packages/async-aws/timestream-write) | [![](https://github.com/async-aws/timestream-write/workflows/BC%20Check/badge.svg?branch=master)](https://github.com/async-aws/timestream-write/actions) | [![](https://async-aws-pr.github.io/commits-since-release-counter/timestream-write.svg)](https://github.com/async-aws/timestream-write/releases) |

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"psr-4": {
5050
"AsyncAws\\AppSync\\": "src/Service/AppSync/src",
5151
"AsyncAws\\Athena\\": "src/Service/Athena/src",
52+
"AsyncAws\\BedrockRuntime\\": "src/Service/BedrockRuntime/src",
5253
"AsyncAws\\CloudFormation\\": "src/Service/CloudFormation/src",
5354
"AsyncAws\\CloudFront\\": "src/Service/CloudFront/src",
5455
"AsyncAws\\CloudWatchLogs\\": "src/Service/CloudWatchLogs/src",
@@ -102,6 +103,7 @@
102103
"psr-4": {
103104
"AsyncAws\\AppSync\\Tests\\": "src/Service/AppSync/tests",
104105
"AsyncAws\\Athena\\Tests\\": "src/Service/Athena/tests",
106+
"AsyncAws\\BedrockRuntime\\Tests\\": "src/Service/BedrockRuntime/tests",
105107
"AsyncAws\\CloudFormation\\Tests\\": "src/Service/CloudFormation/tests",
106108
"AsyncAws\\CloudFront\\Tests\\": "src/Service/CloudFront/tests",
107109
"AsyncAws\\CloudWatchLogs\\Tests\\": "src/Service/CloudWatchLogs/tests",

couscous.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ menu:
3737
athena:
3838
text: Athena
3939
url: /clients/athena.html
40+
bedrock-runtime:
41+
text: Bedrock Runtime
42+
url: /clients/bedrock-runtime.html
4043
cf:
4144
text: Cloud Formation
4245
url: /clients/cf.html

docs/clients/bedrock-runtime.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: client
3+
category: clients
4+
name: BedrockRuntime
5+
package: async-aws/bedrock-runtime
6+
---
7+
8+
## Usage
9+
10+
### InvokeModel
11+
12+
```php
13+
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
14+
use AsyncAws\BedrockRuntime\Input\InvokeModelRequest;
15+
16+
$bedrockRuntime = new BedrockRuntimeClient();
17+
18+
$body = [
19+
'anthropic_version' => 'bedrock-2023-05-31',
20+
'max_tokens' => 4096,
21+
'messages' => [
22+
[
23+
'role' => 'user',
24+
'content' => [
25+
['type' => 'text', 'text' => 'Write me a love poem.']
26+
]
27+
]
28+
],
29+
'temperature' => 1
30+
];
31+
32+
$result = $bedrockRuntime->invokeModel(new InvokeModelRequest([
33+
'modelId' => 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
34+
'contentType' => 'application/json',
35+
'body' => json_encode($body, JSON_THROW_ON_ERROR)
36+
]));
37+
38+
$response = json_decode($result->getBody(), true, 512, JSON_THROW_ON_ERROR);
39+
40+
echo $response['content'][0]['text'];
41+
42+
```
43+
more information [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html)

docs/clients/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ for more information.
139139
|---------------------------------------------|-----------------------------------------------------------------------------------------------------------|
140140
| [AppSync](./app-sync.md) | [async-aws/app-sync](https://packagist.org/packages/async-aws/app-sync) |
141141
| [Athena](./athena.md) | [async-aws/athena](https://packagist.org/packages/async-aws/athena) |
142+
| [BedrockRuntime](./bedrock-runtime.md) | [async-aws/bedrock-runtime](https://packagist.org/packages/async-aws/bedrock-runtime) |
142143
| [CloudFormation](./cf.md) | [async-aws/cloud-formation](https://packagist.org/packages/async-aws/cloud-formation) |
143144
| [CloudFront](./cloud-front.md) | [async-aws/cloud-front](https://packagist.org/packages/async-aws/cloud-front) |
144145
| [CloudWatch](./cloud-watch.md) | [async-aws/cloud-watch](https://packagist.org/packages/async-aws/cloud-watch) |

manifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
]
6565
}
6666
},
67+
"BedrockRuntime": {
68+
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/api-2.json",
69+
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/docs-2.json",
70+
"pagination": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/paginators-1.json",
71+
"example": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/examples-1.json",
72+
"api-reference": "https://docs.aws.amazon.com/bedrock/latest/APIReference",
73+
"methods": [
74+
"InvokeModel"
75+
]
76+
},
6777
"CloudFormation": {
6878
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/api-2.json",
6979
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/cloudformation/2010-05-15/docs-2.json",

src/Core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- AWS api-change: Added `us-isof-east-1` and `us-isof-south-1` regions
8+
- Support for BedrockRuntime
89

910
## 1.24.1
1011

src/Core/src/AwsClientFactory.php

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

77
use AsyncAws\AppSync\AppSyncClient;
88
use AsyncAws\Athena\AthenaClient;
9+
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
910
use AsyncAws\CloudFormation\CloudFormationClient;
1011
use AsyncAws\CloudFront\CloudFrontClient;
1112
use AsyncAws\CloudWatch\CloudWatchClient;
@@ -118,6 +119,19 @@ public function appSync(): AppSyncClient
118119
return $this->serviceCache[__METHOD__];
119120
}
120121

122+
public function bedrockRuntime(): BedrockRuntimeClient
123+
{
124+
if (!class_exists(BedrockRuntimeClient::class)) {
125+
throw MissingDependency::create('async-aws/bedrock-runtime', 'BedrockRuntime');
126+
}
127+
128+
if (!isset($this->serviceCache[__METHOD__])) {
129+
$this->serviceCache[__METHOD__] = new BedrockRuntimeClient($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger);
130+
}
131+
132+
return $this->serviceCache[__METHOD__];
133+
}
134+
121135
public function cloudFormation(): CloudFormationClient
122136
{
123137
if (!class_exists(CloudFormationClient::class)) {

src/Integration/Symfony/Bundle/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## NOT RELEASED
44

5+
### Added
6+
7+
- Support for BedrockRuntime
8+
59
## 1.13.0
610

711
### Added

src/Integration/Symfony/Bundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"extra": {
4141
"branch-alias": {
42-
"dev-master": "1.13-dev"
42+
"dev-master": "1.14-dev"
4343
}
4444
}
4545
}

0 commit comments

Comments
 (0)