-
Notifications
You must be signed in to change notification settings - Fork 971
Pattern update - apigw-lambda-bedrock-cdk-python #2723
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
# Text generation via ApiGateway -> Lambda -> Bedrock | ||||||
# Text generation via Amazon API Gateway -> AWS Lambda -> Amazon Bedrock | ||||||
|
||||||
 | ||||||
|
||||||
|
@@ -18,27 +18,27 @@ Important: this application uses various AWS services and there are costs associ | |||||
## Amazon Bedrock setup instructions | ||||||
You must request access to a model before you can use it. If you try to use the model (with the API or console) before you have requested access to it, you receive an error message. For more information, see [Model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html). | ||||||
|
||||||
1. In the AWS console, select the region from which you want to access Amazon Bedrock. At the time of writing, Amazon Bedrock is available in us-east-1 (N. Virginia) and us-west-2 (Oregon) regions. | ||||||
1. In the AWS console, select the region from which you want to access Amazon Bedrock. At the time of writing, Amazon Bedrock is available in most major regions. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
 | ||||||
|
||||||
1. Find **Amazon Bedrock** by searching in the AWS console. | ||||||
|
||||||
 | ||||||
 | ||||||
|
||||||
1. Expand the side menu. | ||||||
|
||||||
 | ||||||
 | ||||||
|
||||||
1. From the side menu, select **Model access**. | ||||||
|
||||||
 | ||||||
 | ||||||
|
||||||
1. Select the **Edit** button. | ||||||
|
||||||
 | ||||||
 | ||||||
|
||||||
6. Use the checkboxes to select the models you wish to enable. Review the applicable EULAs as needed. Click **Save changes** to activate the models in your account. For this pattern we only need Anthropic/Claude but feel free to experiment with others. | ||||||
6. Use the checkboxes to select the models you wish to enable. Review the applicable EULAs as needed. Click **Save changes** to activate the models in your account. For this pattern we only need Anthropic Claude 3 Haiku but feel free to experiment with others. | ||||||
|
||||||
## Deployment Instructions | ||||||
|
||||||
|
@@ -74,14 +74,14 @@ You must request access to a model before you can use it. If you try to use the | |||||
``` | ||||||
cdk deploy | ||||||
``` | ||||||
1. After deployment completes, take a look at the Outputs section. There will be an entry containing the URL of the API Gateway resource you just created. Copy that URL as you'll need it for your tests. | ||||||
1. After deployment completes, take a look at the Outputs section. There will be an entry containing the URL of the Amazon API Gateway resource you just created. Copy that URL as you'll need it for your tests. | ||||||
|
||||||
The format of the URL will be something like `https://{id}.execute-api.{region}.amazonaws.com/prod` | ||||||
|
||||||
|
||||||
## How it works | ||||||
|
||||||
CDK will create an Api Gateway, along with a resource and a POST method. There's a AWS Lambda function that will be taking the prompt and invoking an Amazon Bedrock model (anthropic.claude-v2) synchronously. If you wish to try other models, make sure to modify the policy attached to the Lambda function and invoke the right model. | ||||||
CDK will create an Amazon API Gateway, along with a resource and a POST method. There is an AWS Lambda function that will be taking the prompt and invoking an Amazon Bedrock model (anthropic.claude-3-haiku-20240307-v1:0) synchronously. If you wish to try other models, make sure to modify the policy attached to the Lambda function and invoke the right model. | ||||||
|
||||||
This pattern is a synchronous pattern. For an asynchronous approach, please check [this](../apigw-rest-api-sqs-lambda-bedrock-cdk) pattern that involves the usage of Amazon SQS. | ||||||
|
||||||
|
@@ -107,7 +107,7 @@ Follow the example below and replace `{your-api-url}` with your api url from ste | |||||
``` | ||||||
|
||||||
## Extra Resources | ||||||
* [Bedrock Api Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html) | ||||||
* [Amazon Bedrock Api Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html) | ||||||
|
||||||
---- | ||||||
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-24.8 KB
(59%)
apigw-lambda-bedrock-cdk-python/architecture/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+153 KB
(190%)
apigw-lambda-bedrock-cdk-python/bedrock_setup/model-access-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please update the title as well to include full service names, e.g. Amazon API Gateway.