GithubHelp home page GithubHelp logo

raymondngkm / amazon-bedrock-streamlit-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hantzley/amazon-bedrock-multimodal-demo-app

0.0 0.0 0.0 7 MB

Streamlit demo application for Amazon Bedrock

License: MIT License

Python 98.89% Dockerfile 1.11%

amazon-bedrock-streamlit-app's Introduction

Streamlit demo application for Amazon Bedrock

This project offers a somple front-end application built with Streamlit to showcase Amazon Bedrock. You can deploy this CDK project in your AWS account. Alternatively, you can run the Streamlit application on your local machine. See sections below for instructions.

Architecture

Architecture

Prequisites

Make sure you have access to the Bedrock models before using this application. You can request access to the Bedrock models through the console:

Model Access

Enable AWS IAM permissions for Bedrock

The AWS identity you assume from your notebook environment (which is the Studio/notebook Execution Role from SageMaker, or could be a role or IAM User for self-managed notebooks), must have sufficient AWS IAM permissions to call the Amazon Bedrock service.

To grant Bedrock access to your identity, you can:

Open the AWS IAM Console Find your Role (if using SageMaker or otherwise assuming an IAM Role), or else User Select Add Permissions > Create Inline Policy to attach new inline permissions, open the JSON editor and paste in the below example policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "BedrockFullAccess",
            "Effect": "Allow",
            "Action": ["bedrock:*"],
            "Resource": "*"
        }
    ]
}

If you are running the application from your local machine, make sure you have the following tools installed:

  • AWS CLI
  • Node.js
  • IDE for your programming language
  • AWS CDK Toolkit (v2.0 or later)
  • Git, JQ, etc
  • Docker

Deploy application in your AWS account

We recommend you use an AWS Cloud9 development enviroment for this project. See this Cloud9 setup guide.

Clone the repository and enter the project directory:

git clone https://github.com/Hantzley/amazon-bedrock-streamlit-app.git
cd amazon-bedrock-streamlit-app

Create a virtualenv on MacOS or Linux:

python3 -m venv .venv

After the init process completes and the virtualenv is created, you can use the following step to activate your virtualenv.

source .venv/bin/activate

Once the virtualenv is activated, you can install the required dependencies.

pip install -r requirements.txt

If your account is not yet boostrapped for CDK, execute the following command:

cdk bootstrap

At this point you can now list the stacks in the project.

cdk ls

You should see the following output:

GenAiBedrockVpcStack
GenAiBedrockWebStack

Deploy the application as a container on Elastic Container Services in our AWS account:

cdk deploy GenAiBedrockWebStack

The GenAiBedrockWebStack depends on GenAiBedrockVpcStack. CDK will resolve that dependency and automatically deploy GenAiBedrockVpcStack first.

Copy the WebApplicationServiceURL from the output and paste it on your browser.

Run application on your local machine

Alternatively, you can execute the Streamlit application on your local machine:

cd web-app
streamlit run Home.py 

The application should open in your browser.

Enjoy!

Clean up

To avoid unnecessary cost, you can destroy the resources used in the project:

cdk deploy --all

Screenshots

Text generation

Text generation

Text summarization

Text summarization

Text to image

Text to image

Image to image

Image to image

amazon-bedrock-streamlit-app's People

Contributors

hantzley avatar

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.