You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of foundation models (FMs) along with a broad set of capabilities for building generative AI applications.
22
+
[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.
23
23
24
-
This construct library includes CloudFormation L1 resources to deploy Bedrock features.
24
+
This construct library facilitates the deployment of Knowledge Bases, Bedrock Agents, Guardrails, Prompt Management, and Inference Pipelines. It leverages underlying CloudFormation L1 resources to provision these Bedrock features.
25
25
26
26
## Table of contents
27
27
@@ -38,7 +38,7 @@ See the [API documentation](../../../apidocs/namespaces/bedrock/README.md).
38
38
39
39
## Knowledge Bases
40
40
41
-
With Knowledge Bases for Amazon Bedrock, you can give FMs and agents contextual information from your company’s private data sources for Retrieval Augmented Generation (RAG) to deliver more relevant, accurate, and customized responses.
41
+
Amazon Bedrock Knowledge Bases enable you to provide foundation models and agents with contextual information from your company’s private data sources. This enhances the relevance, accuracy, and customization of their responses.
42
42
43
43
### Create a Knowledge Base
44
44
@@ -48,6 +48,25 @@ The resource accepts an `instruction` prop that is provided to any Bedrock Agent
48
48
49
49
Amazon Bedrock Knowledge Bases currently only supports S3 as a data source. The `S3DataSource` resource is used to configure how the Knowledge Base handles the data source.
50
50
51
+
## Knowledge Base Properties
52
+
53
+
54
+
| Name | Type | Required | Description |
55
+
|---|---|---|---|
56
+
| embeddingsModel | BedrockFoundationModel | Yes | The embeddings model for the knowledge base |
57
+
| name | string | No | The name of the knowledge base |
58
+
| description | string | No | The description of the knowledge base |
59
+
| instruction | string | No | Instructions for agents based on the design and type of information of the Knowledge Base that will impact how Agents interact with the Knowledge Base |
60
+
| existingRole | iam.IRole | No | Existing IAM role with a policy statement granting permission to invoke the specific embeddings model |
61
+
| indexName | string | No | The name of the vector index (only applicable if vectorStore is of type VectorCollection) |
62
+
| vectorField | string | No | The name of the field in the vector index (only applicable if vectorStore is of type VectorCollection) |
63
+
| vectorStore | VectorCollection \| PineconeVectorStore \| AmazonAuroraVectorStore \| ExistingAmazonAuroraVectorStore | No | The vector store for the knowledge base |
64
+
| vectorIndex | VectorIndex | No | The vector index for the OpenSearch Serverless backed knowledge base |
65
+
| knowledgeBaseState | string | No | Specifies whether to use the knowledge base or not when sending an InvokeAgent request |
66
+
| tags | Record<string, string> | No | Tag (KEY-VALUE) bedrock agent resource |
67
+
68
+
## Initializer
69
+
51
70
Example of `OpenSearch Serverless`:
52
71
53
72
TypeScript
@@ -595,7 +614,7 @@ class PythonTestStack(Stack):
595
614
Python
596
615
597
616
```python
598
-
ChunkingStrategy.DEFAULT;
617
+
ChunkingStrategy.DEFAULT
599
618
```
600
619
601
620
-**Fixed Size Chunking**: This method divides the data into fixed-size chunks, with each chunk
Enable generative AI applications to execute multistep tasks across company systems and data sources.
791
+
Amazon Bedrock Agents allow generative AI applications to automate complex, multistep tasks by seamlessly integrating with your company’s systems, APIs, and data sources.
792
+
793
+
794
+
### Agent Properties
795
+
796
+
| Name | Type | Required | Description |
797
+
|---|---|---|---|
798
+
| name | string | No | The name of the agent. Defaults to a name generated by CDK |
799
+
| instruction | string | Yes | The instruction used by the agent that determines how it will perform its task. Must have a minimum of 40 characters |
800
+
| foundationModel | IInvokable | Yes | The foundation model used for orchestration by the agent |
801
+
| existingRole | iam.IRole | No | The existing IAM Role for the agent to use. Must have a trust policy allowing Bedrock service to assume the role. Defaults to a new created role |
802
+
| shouldPrepareAgent | boolean | No | Specifies whether to automatically update the `DRAFT` version of the agent after making changes. Defaults to false |
803
+
| idleSessionTTL | Duration | No | How long sessions should be kept open for the agent. Session expires if no conversation occurs during this time. Defaults to 1 hour |
804
+
| kmsKey | kms.IKey | No | The KMS key of the agent if custom encryption is configured. Defaults to AWS managed key |
805
+
| description | string | No | A description of the agent. Defaults to no description |
806
+
| knowledgeBases | IKnowledgeBase[]| No | The KnowledgeBases associated with the agent |
807
+
| actionGroups | AgentActionGroup[]| No | The Action Groups associated with the agent |
808
+
| guardrail | IGuardrail | No | The guardrail that will be associated with the agent |
809
+
| promptOverrideConfiguration | PromptOverrideConfiguration | No | Overrides some prompt templates in different parts of an agent sequence configuration |
810
+
| userInputEnabled | boolean | No | Select whether the agent can prompt additional information from the user when it lacks enough information. Defaults to false |
811
+
| codeInterpreterEnabled | boolean | No | Select whether the agent can generate, run, and troubleshoot code when trying to complete a task. Defaults to false |
812
+
| forceDelete | boolean | No | Whether to delete the resource even if it's in use. Defaults to true |
773
813
774
814
### Create an Agent
775
815
776
816
The following example creates an Agent with a simple instruction and default prompts that consults a Knowledge Base.
instruction="You are a helpful and friendly agent that answers questions about insurance claims.",
797
839
)
798
-
agent.add_knowledge_base(kb);
840
+
agent.add_knowledge_base(kb)
799
841
```
800
842
801
843
You can also use system defined inference profiles to enable cross region inference requests for supported models. For instance:
@@ -836,6 +878,22 @@ For more information on cross region inference, please refer to [System defined
836
878
837
879
An action group defines functions your agent can call. The functions are Lambda functions. The action group uses an OpenAPI schema to tell the agent what your functions do and how to call them.
838
880
881
+
### Action Group Properties
882
+
883
+
| Name | Type | Required | Description |
884
+
|---|---|---|---|
885
+
| name | string | Yes | The name of the action group |
886
+
| description | string | No | A description of the action group |
887
+
| apiSchema | ApiSchema | No | The API Schema |
888
+
| executor | ActionGroupExecutor | No | The action group executor |
889
+
| enabled | boolean | No | Specifies whether the action group is available for the agent to invoke or not when sending an InvokeAgent request. Defaults to true |
890
+
| forceDelete | boolean | No | Specifies whether to delete the resource even if it's in use. Defaults to false |
891
+
| functionSchema | CfnAgent.FunctionSchemaProperty | No | Defines functions that each define parameters that the agent needs to invoke from the user |
892
+
| parentActionGroupSignature | ParentActionGroupSignature | No | The AWS Defined signature for enabling certain capabilities in your agent. When specified, description, apiSchema, and actionGroupExecutor must be blank |
prompt_text="This is my second text prompt. Please summarize our conversation on: {{topic}}.",
1446
+
inference_configuration={
1447
+
"temperature": 0.5,
1448
+
"topP": 0.999,
1449
+
"maxTokens": 2000,
1450
+
}
1451
+
)
1452
+
1453
+
prompt.add_variant(variant2)
1454
+
```
1290
1455
1291
1456
### Prompt routing
1292
1457
@@ -1344,12 +1509,21 @@ to update the version whenever a certain configuration property changes.
1344
1509
newPromptVersion(prompt1, 'my first version');
1345
1510
```
1346
1511
1512
+
```python
1513
+
bedrock.PromptVersion(self, "my first version")
1514
+
1515
+
```
1516
+
1347
1517
or alternatively:
1348
1518
1349
1519
```ts
1350
1520
prompt1.createVersion('my first version');
1351
1521
```
1352
1522
1523
+
```python
1524
+
prompt.create_version("version1", "my first version")
1525
+
```
1526
+
1353
1527
## System defined inference profiles
1354
1528
1355
1529
You can build a CrossRegionInferenceProfile using a system defined inference profile. The inference profile will route requests to the Regions defined in the cross region (system-defined) inference profile that you choose. You can find the system defined inference profiles by navigating to your console (Amazon Bedrock -> Cross-region inference) or programmatically, for instance using [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock/client/list_inference_profiles.html).
0 commit comments