Giter Club home page Giter Club logo

aws-bedrock-with-rag-and-react's Introduction

RAG with AWS Bedrock and React

Use this solution to quickly and inexpensively begin prototyping and vetting business use cases for GenAI using a custom corpus of knowledge with Retrieval Augmented Generation (RAG) in a low-code ReactJS application.

This solution contains a backend Flask application which uses LangChain to provide PDF data as embeddings to your choice of text-gen foundational model via Amazon Web Services (AWS) new, managed LLM-provider service, Amazon Bedrock and your choice of vector database with FAISS or a Kendra Index.

What You'll Build

Bedrock Demo Architecture

Screenshots

Bedrock Demo FrontEnd

Prerequisites

  1. AWS CDK
  2. Node.js & npm
  3. Python 3.8 or higher
  4. AWS CLI configured with appropriate permissions

How to Deploy

  1. Clone the repository and navigate to the project directory.

  2. Install the Python dependencies for the CDK Deployment:

    pip install -r requirements.txt
    
  3. Bootstrap CDK (if not already done): If this is your first time using CDK in this AWS account and region, you need to bootstrap CDK. This command deploys a CDK toolkit stack to your account that helps with asset management:

    cdk bootstrap aws://YOUR_ACCOUNT_NUMBER/YOUR_REGION
    

    Replace YOUR_ACCOUNT_NUMBER with your AWS account number and YOUR_REGION with your desired AWS region.

  4. Deploy the Backend CDK stack.

    cdk deploy BedrockDemo-BackendStack
    
  5. Redeploy the frontend stack to update the proxy URL:

    cdk deploy BedrockDemo-FrontendStack
    

Your application should now be accessible at the frontend URL provided by the CDK output.

How to Use

Once you confirm that the app(s) are running, you can begin prototyping.

Add Your Own Corpus for RAG Embeddings

PDF data is read from ./backend/flask/output and stored in an in-memory vector database using FAISS when the Flask app is started. If you add or remove PDF data from the ./backend/flask/output directory, you'll need to restart the Flask application for the changes to take effect.

Alternatively, you can use the database button in the lower right corner of the application to add or remove PDF documents manually or from S3 and subsequently reinstantiate the in-memory vector database, or instantiate a connection to a Kendra index.

Prompt Engineering with LangChain

Use the </> button just above the database button to update the Prompt Template: explicit instructions for how a text-gen model should respond.

Foundational Models are trained in specific ways to interact with prompts. Check out the Claude Documentation Page to learn best practices and find examples of pre-engineered prompts.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-bedrock-with-rag-and-react's People

Contributors

amazon-auto avatar dependabot[bot] avatar dkovvuri avatar marshallbunch avatar mdaftarirp avatar shadhav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aws-bedrock-with-rag-and-react's Issues

CORS Error: Response to preflight request doesn't pass access control check

Hello, after following the instructions in the README to run the python server and the react client, I am seeing several CORS errors in the browser javascript console. How can I resolve the CORS error?

Following are the errors that I see repeated in the console. The errors appear periodically without any interaction, and also when I attempt to upload a PDF using the FAISS dialog UI.

Access to fetch at 'http://localhost:5000/api/check-vector' from origin 'http://localhost:3000'
has been blocked by CORS policy: Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response
serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

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.