GenAI Builder is a generative AI solution based on Amazon Bedrock services.
Introducing Amazon Bedrock: Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon via a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI. Using Amazon Bedrock, you can easily experiment with and evaluate top FMs for your use case, privately customize them with your data using techniques such as fine-tuning and Retrieval Augmented Generation (RAG), and build agents that execute tasks using your enterprise systems and data sources. Since Amazon Bedrock is serverless, you don't have to manage any infrastructure, and you can securely integrate and deploy generative AI capabilities into your applications using the AWS services you are already familiar with.
Goal:
- Help users use Bedrock services more conveniently and understand the capabilities of generative AI;
- Help users quickly leverage Bedrock to develop, deploy, and industrialize GenAI application projects;
Features:
- One-click deployment, simple and convenient;
- Use ServerLess services for development and scheduling, low cost;
[This solution is only for PoC, not Amazon web service official solution]
Here is a video to demostrate how to deploy this solution.
-
Chinese Language:
-
EC2 with Amazon Linux 2023
- AMI: Amazon Linux 2023 x86
- Instance Type: t3.xlarge
- EBS: >=10GB
- Network: Public access with SSH
-
AWS CLI Upgrade
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
If you are using Linux x86, the following script can used to upgrade: to makke sure your AWS cli version >= 2.15.4
sudo yum update -y curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
-
AWS CDK Upgrade
to makke sure your CDK version >= 2.116.1 and npm version >= 10.2.5
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash . ~/.nvm/nvm.sh nvm install v18.19.0 sudo yum install nodejs npm -y curl -qL https://www.npmjs.com/install.sh | sh sudo npm install -g typescript -y sudo npm install -g aws-cdk -y cdk --version npm --version
-
AWSCurl https://github.com/okigan/awscurl
sudo yum install pip -y pip install awscurl awscurl
-
Set Local Access Key and Secret Key, use a user access key which has access to deploy.
Prepare an access key first, which have access to create releated resources.
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
Then set up the aws cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html#getting-started-quickstart-new-command
aws configure
sudo yum install git -y
git clone https://github.com/cloudswb/aws-genai-bedrock-builder.git
We can customize the project name prefix, this prefix will add to the CDK stack and Lambda function name.
cd aws-genai-bedrock-builder/
vim bin/config.ts
Now you can modify this config file according the following comments:
export const Config = {
DomainName: 'xxx.com', // The domain name (will combine with <SiteSubDomain> to create a S3 bucket name like: <SiteSubDomain>.<DomainName>)
SiteSubDomain: 'genai-dev', // will combine with <DomainName> to create a S3 bucket name like: <SiteSubDomain>.<DomainName>
Region: "us-east-1", // Target region will be deploy, the region should have bedrock\opensearch serverless available.
Auth: 'iam', //Auth type, DO NOT Change, we only support this IAM auth type currently.
KBEmbeddingModelName: "amazon.titan-embed-text-v1", //Knowledge base Embedding Model ID
KBLLMName: "anthropic.claude-v2", // Knowledge base LLM ID
AgentLLMName: "anthropic.claude-v2", // Bedrock agent LLM ID
}
Run the following shell script to deploy all services:
sudo npm install
chmod +x ./bin/deploy.sh
./bin/deploy.sh
After deploy finished, there will have a CloudFront distribution info print out.
You can open the CloudFront distribution link directly, but to use the system, you should create a user in Cognito user pool first.
You can get the Cognito info from CloudFormation service, the stack name should like “[XXX]CognitoUserPoolStack”.
Open the user pool and create a new user with customized username and password.
Get the output of the CloudFront distribution address from you shell client: like the url : d21wi5ogab28wm.cloudfront.net.
You also can get this CloudFront distribution address from output information of CloudFormation stack (stack name like [xxx]).
chmod +x ./bin/destroy.sh
./bin/destroy.sh
Sometimes to fix a issue or use to new feature, you may need to upgrade the solution.
-
Delete lambda function and Frontend website.
Generally you only need to delete the following Stack from CloudFormation Service:
- GenAIBuilderCloudFrontWebsiteStack
- GenAIBuilderLambdaFunctionStack
If you want delete all resources, you may refer to section 4 to destroy all(include knowledgebase and agent).
chmod +x ./bin/destroy.sh ./bin/destroy.sh
-
Backup the config file
// backup the pre configed file as the following commands may override this file
cp bin/config.ts bin/config.ts.backup
-
Force to get latest sourcecode
git checkout . git pull
-
Re-Deploy the solution
sudo npm install chmod +x ./bin/deploy.sh ./bin/deploy.sh