Skip to content

Commit c5010cc

Browse files
committed
Add BedrockAgent client
1 parent f26e48d commit c5010cc

File tree

70 files changed

+4248
-1
lines changed

Some content is hidden

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

70 files changed

+4248
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
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) | [![BC Check](https://github.com/async-aws/core/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/core/actions/workflows/checks.yml) | [![](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) | [![BC Check](https://github.com/async-aws/app-sync/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/app-sync/actions/workflows/checks.yml) | [![](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) | [![BC Check](https://github.com/async-aws/athena/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/athena/actions/workflows/checks.yml) | [![](https://async-aws-pr.github.io/commits-since-release-counter/athena.svg)](https://github.com/async-aws/athena/releases) |
16+
| [async-aws/bedrock-agent](https://github.com/async-aws/bedrock-agent) | [![Latest Stable Version](https://poser.pugx.org/async-aws/bedrock-agent/v/stable)](https://packagist.org/packages/async-aws/bedrock-agent) [![Total Downloads](https://poser.pugx.org/async-aws/bedrock-agent/downloads)](https://packagist.org/packages/async-aws/bedrock-agent) | [![BC Check](https://github.com/async-aws/bedrock-agent/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/bedrock-agent/actions/workflows/checks.yml) | [![](https://async-aws-pr.github.io/commits-since-release-counter/bedrock-agent.svg)](https://github.com/async-aws/bedrock-agent/releases) |
1617
| [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) | [![BC Check](https://github.com/async-aws/bedrock-runtime/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/bedrock-runtime/actions/workflows/checks.yml) | [![](https://async-aws-pr.github.io/commits-since-release-counter/bedrock-runtime.svg)](https://github.com/async-aws/bedrock-runtime/releases) |
1718
| [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) | [![BC Check](https://github.com/async-aws/cloud-formation/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/cloud-formation/actions/workflows/checks.yml) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-formation.svg)](https://github.com/async-aws/cloud-formation/releases) |
1819
| [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) | [![BC Check](https://github.com/async-aws/cloud-front/actions/workflows/checks.yml/badge.svg?branch=master)](https://github.com/async-aws/cloud-front/actions/workflows/checks.yml) | [![](https://async-aws-pr.github.io/commits-since-release-counter/cloud-front.svg)](https://github.com/async-aws/cloud-front/releases) |

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"psr-4": {
5353
"AsyncAws\\AppSync\\": "src/Service/AppSync/src",
5454
"AsyncAws\\Athena\\": "src/Service/Athena/src",
55+
"AsyncAws\\BedrockAgent\\": "src/Service/BedrockAgent/src",
5556
"AsyncAws\\BedrockRuntime\\": "src/Service/BedrockRuntime/src",
5657
"AsyncAws\\CloudFormation\\": "src/Service/CloudFormation/src",
5758
"AsyncAws\\CloudFront\\": "src/Service/CloudFront/src",
@@ -106,6 +107,7 @@
106107
"psr-4": {
107108
"AsyncAws\\AppSync\\Tests\\": "src/Service/AppSync/tests",
108109
"AsyncAws\\Athena\\Tests\\": "src/Service/Athena/tests",
110+
"AsyncAws\\BedrockAgent\\Tests\\": "src/Service/BedrockAgent/tests",
109111
"AsyncAws\\BedrockRuntime\\Tests\\": "src/Service/BedrockRuntime/tests",
110112
"AsyncAws\\CloudFormation\\Tests\\": "src/Service/CloudFormation/tests",
111113
"AsyncAws\\CloudFront\\Tests\\": "src/Service/CloudFront/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-agent:
41+
text: Bedrock Agent
42+
url: /clients/bedrock-agent.html
4043
bedrock-runtime:
4144
text: Bedrock Runtime
4245
url: /clients/bedrock-runtime.html

docs/clients/bedrock-agent.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
layout: client
3+
category: clients
4+
name: BedrockAgent
5+
package: async-aws/bedrock-agent
6+
---
7+
8+
## Usage
9+
10+
### Delete knowledge base documents
11+
12+
```php
13+
use AsyncAws\BedrockAgent\BedrockAgentClient;
14+
use AsyncAws\BedrockAgent\Enum\ContentDataSourceType;
15+
use AsyncAws\BedrockAgent\Input\DeleteKnowledgeBaseDocumentsRequest;
16+
use AsyncAws\BedrockAgent\ValueObject\DocumentIdentifier;
17+
use AsyncAws\BedrockAgent\ValueObject\S3Location;
18+
19+
$bedrockAgent = new BedrockAgentClient();
20+
21+
$request = new DeleteKnowledgeBaseDocumentsRequest([
22+
'knowledgeBaseId' => 'kb-1234567890abcdef',
23+
'dataSourceId' => 'ds-abcdef1234567890',
24+
'clientToken' => 'token-1234',
25+
'documentIdentifiers' => [new DocumentIdentifier([
26+
'dataSourceType' => ContentDataSourceType::S3,
27+
's3' => new S3Location([
28+
'uri' => 's3://my-bucket/documents/',
29+
]),
30+
])],
31+
]);
32+
33+
$result = $bedrockAgent->deleteKnowledgeBaseDocuments($request);
34+
35+
foreach ($result->getDocumentDetails() as $documentDetail) {
36+
echo $documentDetail->getStatus() . PHP_EOL;
37+
}
38+
39+
```
40+
more information [DeleteKnowledgeBaseDocuments](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_DeleteKnowledgeBaseDocuments.html)
41+
42+
### Get knowledge base documents
43+
44+
```php
45+
use AsyncAws\BedrockAgent\BedrockAgentClient;
46+
use AsyncAws\BedrockAgent\Enum\ContentDataSourceType;
47+
use AsyncAws\BedrockAgent\Input\GetKnowledgeBaseDocumentsRequest;
48+
use AsyncAws\BedrockAgent\ValueObject\DocumentIdentifier;
49+
use AsyncAws\BedrockAgent\ValueObject\S3Location;
50+
51+
$bedrockAgent = new BedrockAgentClient();
52+
53+
$request = new GetKnowledgeBaseDocumentsRequest([
54+
'knowledgeBaseId' => 'kb-1234567890abcdef',
55+
'dataSourceId' => 'ds-abcdef1234567890',
56+
'documentIdentifiers' => [new DocumentIdentifier([
57+
'dataSourceType' => ContentDataSourceType::S3,
58+
's3' => new S3Location([
59+
'uri' => 's3://my-bucket/documents/',
60+
]),
61+
])],
62+
]);
63+
64+
$result = $bedrockAgent->getKnowledgeBaseDocuments($request);
65+
66+
foreach ($result->getDocumentDetails() as $documentDetail) {
67+
echo $documentDetail->getIdentifier()->getS3()->getUri() . PHP_EOL;
68+
}
69+
70+
```
71+
more information [GetKnowledgeBaseDocuments](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_GetKnowledgeBaseDocuments.html)
72+
73+
### Ingest knowledge base documents
74+
75+
```php
76+
use AsyncAws\BedrockAgent\Enum\ContentDataSourceType;
77+
use AsyncAws\BedrockAgent\Enum\MetadataSourceType;
78+
use AsyncAws\BedrockAgent\Input\IngestKnowledgeBaseDocumentsRequest;
79+
use AsyncAws\BedrockAgent\ValueObject\CustomS3Location;
80+
use AsyncAws\BedrockAgent\ValueObject\DocumentContent;
81+
use AsyncAws\BedrockAgent\ValueObject\DocumentMetadata;
82+
use AsyncAws\BedrockAgent\ValueObject\KnowledgeBaseDocument;
83+
use AsyncAws\BedrockAgent\ValueObject\S3Content;
84+
use AsyncAws\BedrockAgent\ValueObject\S3Location;
85+
86+
$bedrockAgent = new BedrockAgentClient();
87+
88+
$request = new IngestKnowledgeBaseDocumentsRequest([
89+
'knowledgeBaseId' => 'kb-1234567890abcdef',
90+
'dataSourceId' => 'ds-abcdef1234567890',
91+
'clientToken' => 'token-1234',
92+
'documents' => [new KnowledgeBaseDocument([
93+
'metadata' => new DocumentMetadata([
94+
'type' => MetadataSourceType::S3_LOCATION,
95+
's3Location' => new CustomS3Location([
96+
'uri' => 's3://my-bucket/documents/',
97+
'bucketOwnerAccountId' => 'account-1234',
98+
]),
99+
]),
100+
'content' => new DocumentContent([
101+
'dataSourceType' => ContentDataSourceType::S3,
102+
's3' => new S3Content([
103+
's3Location' => new S3Location([
104+
'uri' => 's3://my-bucket/documents/',
105+
]),
106+
]),
107+
]),
108+
])],
109+
]);
110+
111+
$result = $bedrockAgent->ingestKnowledgeBaseDocuments($request);
112+
113+
foreach ($result->getDocumentDetails() as $documentDetail) {
114+
echo $documentDetail->getStatus() . PHP_EOL;
115+
echo $documentDetail->getIdentifier()->getS3()->getUri() . PHP_EOL;
116+
}
117+
118+
```
119+
more information [IngestKnowledgeBaseDocuments](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_IngestKnowledgeBaseDocuments.html)
120+
121+
### List knowledge base documents
122+
123+
```php
124+
use AsyncAws\BedrockAgent\BedrockAgentClient;
125+
use AsyncAws\BedrockAgent\Input\ListKnowledgeBaseDocumentsRequest;
126+
127+
$bedrockAgent = new BedrockAgentClient();
128+
129+
$request = new ListKnowledgeBaseDocumentsRequest([
130+
'knowledgeBaseId' => 'kb-1234567890abcdef',
131+
'dataSourceId' => 'ds-abcdef1234567890',
132+
'maxResults' => 50,
133+
]);
134+
135+
$result = $bedrockAgent->listKnowledgeBaseDocuments($request);
136+
137+
foreach ($result->getDocumentDetails() as $documentDetail) {
138+
echo $documentDetail->getIdentifier()->getS3()->getUri() . PHP_EOL;
139+
}
140+
141+
```
142+
more information [ListKnowledgeBaseDocuments](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ListKnowledgeBaseDocuments.html)

docs/clients/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ 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) |
142+
| [BedrockAgent](./bedrock-agent.md) | [async-aws/bedrock-agent](https://packagist.org/packages/async-aws/bedrock-agent) |
143+
| [BedrockRuntime](./bedrock-runtime.md) | [async-aws/bedrock-runtime](https://packagist.org/packages/async-aws/bedrock-runtime) |
143144
| [CloudFormation](./cf.md) | [async-aws/cloud-formation](https://packagist.org/packages/async-aws/cloud-formation) |
144145
| [CloudFront](./cloud-front.md) | [async-aws/cloud-front](https://packagist.org/packages/async-aws/cloud-front) |
145146
| [CloudWatch](./cloud-watch.md) | [async-aws/cloud-watch](https://packagist.org/packages/async-aws/cloud-watch) |

manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@
6464
]
6565
}
6666
},
67+
"BedrockAgent": {
68+
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-agent/2023-06-05/api-2.json",
69+
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-agent/2023-06-05/docs-2.json",
70+
"pagination": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-agent/2023-06-05/paginators-1.json",
71+
"waiter": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-agent/2023-06-05/waiters-2.json",
72+
"example": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-agent/2023-06-05/examples-1.json",
73+
"api-reference": "https://docs.aws.amazon.com/bedrock/latest/APIReference",
74+
"methods": [
75+
"DeleteKnowledgeBaseDocuments",
76+
"GetKnowledgeBaseDocuments",
77+
"IngestKnowledgeBaseDocuments",
78+
"ListKnowledgeBaseDocuments"
79+
]
80+
},
6781
"BedrockRuntime": {
6882
"source": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/api-2.json",
6983
"documentation": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/bedrock-runtime/2023-09-30/docs-2.json",

src/Core/CHANGELOG.md

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

77
- AWS api-change: Added `us-isob-west-1` region
88
- Added `DescribeLogGroups` method
9+
- Support for BedrockAgent
910

1011
### Dependency bumped
1112

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\BedrockAgent\BedrockAgentClient;
910
use AsyncAws\BedrockRuntime\BedrockRuntimeClient;
1011
use AsyncAws\CloudFormation\CloudFormationClient;
1112
use AsyncAws\CloudFront\CloudFrontClient;
@@ -119,6 +120,19 @@ public function appSync(): AppSyncClient
119120
return $this->serviceCache[__METHOD__];
120121
}
121122

123+
public function bedrockAgent(): BedrockAgentClient
124+
{
125+
if (!class_exists(BedrockAgentClient::class)) {
126+
throw MissingDependency::create('async-aws/bedrock-agent', 'BedrockAgent');
127+
}
128+
129+
if (!isset($this->serviceCache[__METHOD__])) {
130+
$this->serviceCache[__METHOD__] = new BedrockAgentClient($this->configuration, $this->credentialProvider, $this->httpClient, $this->logger);
131+
}
132+
133+
return $this->serviceCache[__METHOD__];
134+
}
135+
122136
public function bedrockRuntime(): BedrockRuntimeClient
123137
{
124138
if (!class_exists(BedrockRuntimeClient::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 BedrockAgent
8+
59
### Dependency bumped
610

711
- Drop support for PHP versions lower than 8.2

src/Integration/Symfony/Bundle/src/DependencyInjection/AwsPackagesProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public static function getAllServices(): array
2222
'class' => \AsyncAws\Athena\AthenaClient::class,
2323
'package' => 'async-aws/athena',
2424
],
25+
'bedrock_agent' => [
26+
'class' => \AsyncAws\BedrockAgent\BedrockAgentClient::class,
27+
'package' => 'async-aws/bedrock-agent',
28+
],
2529
'bedrock_runtime' => [
2630
'class' => \AsyncAws\BedrockRuntime\BedrockRuntimeClient::class,
2731
'package' => 'async-aws/bedrock-runtime',

0 commit comments

Comments
 (0)