Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bedrock L2 Construct #688

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Bedrock L2 Construct #688

wants to merge 2 commits into from

Conversation

dineshSajwan
Copy link

This is a request for Amazon Bedrock L2 construct that simplifies the creation of multiple Bedrock features by providing a wrapper over the Bedrock L1 construct. It exposes functions that enable users to create features with minimal code. Key features include Bedrock Agent, Knowledge Base, Guardrails, Inference Profiles, and Prompt. See #686 for
additional details.

APIs are signed off by @{BAR_RAISER}.


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache-2.0 license

Copy link

@hrudu-dev hrudu-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the document is well-structured and provides a comprehensive overview of the Bedrock L2 construct. However, enhancing clarity in certain sections and ensuring completeness will greatly benefit users.


The Bedrock L2 construct simplifies the creation of multiple Bedrock features by providing a wrapper over the Bedrock L1 construct. It exposes functions that enable users to create features with minimal code. Key features include Bedrock Agent, Knowledge Base, Guardrails, Inference Profiles, and Prompt.


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure that all sections of the new construct are complete and provide sufficient details for users to understand and implement the construct.

For more details please refer here [Amazon Bedrock README](https://github.com/awslabs/generative-ai-cdk-constructs/blob/main/src/cdk-lib/bedrock/README.md).


## Knowledge Base

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify that the documentation (README) is clear and includes examples for each feature of the Bedrock L2 construct. It should also explain how to integrate with other AWS services.Verify that the documentation (README) is clear and includes examples for each feature of the Bedrock L2 construct. It should also explain how to integrate with other AWS services.

const auroraDb = aurora.AmazonAuroraVectorStore.fromExistingAuroraVectorStore(stack, 'ExistingAuroraVectorStore', {
clusterIdentifier: 'aurora-serverless-vector-cluster',
databaseName: 'bedrock_vector_db',
schemaName: 'bedrock_integration',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm that all chunking strategies are thoroughly explained and example code is provided for each (Fixed Size, Hierarchical, Semantic, etc.


const kb = new KnowledgeBase(stack, 'MyKnowledgeBase', {
name: 'MyKnowledgeBase',
embeddingsModel: BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the guardrails to ensure that they cover all necessary areas for content filtering, denied topics, word filtering, and sensitive information filters.


- **Fixed Size Chunking**: This method divides the data into fixed-size chunks, with each chunk
containing a predetermined number of tokens. This strategy is useful when the data is uniform
in size and structure.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adhering to AWS best practices, especially in areas involving security (e.g., handling AWS Secrets Manager, IAM roles).


const variant2 = PromptVariant.text({
variantName: "variant2",
model: claudeModel,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a section on how users can provide feedback or report issues with the Bedrock L2 construct.


## Prompt management

Amazon Bedrock provides the ability to create and save prompts using Prompt management so that you can save

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify the versioning strategy for the constructs. It’s important for users to know how to manage updates and changes.

blockedOutputsMessaging: 'blockedOutputsMessaging',
name: 'namemycfnguardrails',
wordPolicyConfig: {
wordsConfig: [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a section on testing the Bedrock L2 construct to ensure users understand how to validate their implementations.


#### Specific version

You can use the `AgentAlias` resource if you want to create an Alias for an existing Agent.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be beneficial to include error handling examples in the documentation to guide users on how to manage potential issues.

### Create an Agent

The following example creates an Agent with a simple instruction and default prompts that consults a Knowledge Base.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that all example code snippets are well-commented and easy to follow. Consider adding more context or explanations for complex sections.

@hrudu-dev
Copy link

I've reviewed the documentation and it looks great! Happy to contribute further if needed. Thank you!


### What are the drawbacks of this solution?

The Knowledge Base vector stores (OpenSearch and Aurora clusters) utilize custom resource lambda functions, as there are no underlying L1 constructs available.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there's CFN resource for OpenSearch collection with vector search. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-opensearchserverless-collection.html

Is it different that what need here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have CFN resource for vector collection but not for vector index creation. The custom resource used here create a vector index. But like we discussed we can skip the vector index part from the construct and enable it to use an existing collection and index.

const importedGuardrail = bedrock.Guardrail.fromCfnGuardrail(cfnGuardrail);
```

Python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the Python code here in readme and RFC.


### Why should we _not_ do this?

The construct is published via the [generative-ai-cdk-constructs](https://github.com/awslabs/generative-ai-cdk-constructs/blob/main/src/cdk-lib/bedrock/README.md) repository. However, due to the increasing demands and expanding use cases, maintaining it within this repository has become challenging.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintaining it within this repository has become challenging.

Why maintaining it within this repo is more challenging than merging into aws-cdk?

```


#### Knowledge Base - Data Sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these APIs just create AWS::Bedrock::DataSource CFN resources?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants