Giter Club home page Giter Club logo

aws-genai-bedrock-builder's Introduction

GenAI Builder Solution

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:

  1. Help users use Bedrock services more conveniently and understand the capabilities of generative AI;
  2. Help users quickly leverage Bedrock to develop, deploy, and industrialize GenAI application projects;

Features:

  1. One-click deployment, simple and convenient;
  2. Use ServerLess services for development and scheduling, low cost;

[This solution is only for PoC, not Amazon web service official solution]

Architecture

Untitled

Deploy Manual

Video : Full deploy progress

Here is a video to demostrate how to deploy this solution.

1. Prepare

  1. EC2 with Amazon Linux 2023

    • AMI: Amazon Linux 2023 x86
    • Instance Type: t3.xlarge
    • EBS: >=10GB
    • Network: Public access with SSH
  2. 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
  3. AWS CDK Upgrade

    https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

    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
  4. AWSCurl https://github.com/okigan/awscurl

    sudo yum install pip -y
    pip install awscurl
    awscurl
  5. 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

2. Deploy

2.1 Get the latest source code from Github

sudo yum install git -y
git clone https://github.com/cloudswb/aws-genai-bedrock-builder.git

2.2 PreConfig deployment

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
}

2.3 Run deployment

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.

3. Run website

You can open the CloudFront distribution link directly, but to use the system, you should create a user in Cognito user pool first.

3.1 Prepare login user in Cognito user pool

You can get the Cognito info from CloudFormation service, the stack name should like “[XXX]CognitoUserPoolStack”.

Untitled

Open the user pool and create a new user with customized username and password.

Untitled

3.2 Run Website deployment

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]).

Untitled

4. Destroy resources

chmod +x ./bin/destroy.sh
./bin/destroy.sh 

5. Upgrade / ReDeploy

Sometimes to fix a issue or use to new feature, you may need to upgrade the solution.

  1. 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 
  2. 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 
  1. Force to get latest sourcecode

     git checkout .
     git pull
  2. Re-Deploy the solution

    sudo npm install
    chmod +x ./bin/deploy.sh
    ./bin/deploy.sh

Features Introduction

drawing Untitled Untitled

aws-genai-bedrock-builder's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.