Giter Club home page Giter Club logo

koushal2018 / aws-genai-llm-chatbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/aws-genai-llm-chatbot

0.0 0.0 0.0 60.76 MB

A modular and comprehensive solution to deploy a Multi-LLM and Multi-RAG powered chatbot (Amazon Bedrock, Anthropic, HuggingFace, OpenAI, AI21, Cohere) using AWS CDK on AWS

License: MIT No Attribution

Shell 0.50% JavaScript 1.94% Python 29.23% TypeScript 67.67% HTML 0.13% Dockerfile 0.03% SCSS 0.49%

aws-genai-llm-chatbot's Introduction

Deploying a Multi-LLM and Multi-RAG Powered Chatbot Using AWS CDK on AWS

Release Notes GitHub star chart License: MIT

sample

Table of content

Features

Modular, comprehensive and ready to use

This solution provides ready-to-use code so you can start experimenting with a variety of Large Language Models, settings and prompts in your own AWS account.

Supported model providers:

Experiment with multiple RAG options with Workspaces

A workspace is a logical namespace where you can upload files for indexing and storage in one of the vector databases. You can select the embeddings model and text-splitting configuration of your choice.

sample

Unlock RAG potentials with Workspaces Debugging Tools

The solution comes with several debugging tools to help you debug RAG scenarios:

  • Run RAG queries without chatbot and analyse results, scores, etc.
  • Test different embeddings models directly in the UI
  • Test cross encoders and analyse distances from different functions between sentences.

sample

Full-fledged User Interface

The repository includes a CDK construct to deploy a full-fledged UI built with React to interact with the deployed LLMs as chatbots. Hosted on Amazon S3 and distributed with Amazon CloudFront.

Protected with Amazon Cognito Authentication to help you interact and experiment with multiple LLMs, multiple RAG engines, conversational history support and document upload/progress.

The interface layer between the UI and backend is built with API Gateway REST API for management requests and Amazon API Gateway WebSocket APIs for chatbot messages and responses.

Design system provided by AWS Cloudscape Design System.

⚠️ Precautions ⚠️

Before you begin using the solution, there are certain precautions you must take into account:

  • Cost Management with self-hosted models on SageMaker: Be mindful of the costs associated with AWS resources, especially with SageMaker models billed by the hour. While the sample is designed to be cost-effective, leaving serverful resources running for extended periods or deploying numerous LLMs can quickly lead to increased costs.

  • Licensing obligations: If you choose to use any datasets or models alongside the provided samples, ensure you check the LLM code and comply with all licensing obligations attached to them.

  • This is a sample: the code provided in this repository shouldn't be used for production workloads without further reviews and adaptation.

Deploy

Environment setup

Deploy with AWS Cloud9

We recommend deploying with AWS Cloud9. If you'd like to use Cloud9 to deploy the solution, you will need the following before proceeding:

  • select at least m5.large as Instance type.
  • use Ubuntu Server 22.04 LTS as the platform.

Local deployment

If you have decided not to use Cloud9, verify that your environment satisfies the following prerequisites:

You have:

  1. An AWS account
  2. AdministratorAccess policy granted to your AWS account (for production, we recommend restricting access as needed)
  3. Both console and programmatic access
  4. NodeJS 16 or 18 installed
    • If you are using nvm you can run the following before proceeding
    • nvm install 16 && nvm use 16
      
      or
      
      nvm install 18 && nvm use 18
      
  5. AWS CLI installed and configured to use with your AWS account
  6. Typescript 3.8+ installed
  7. AWS CDK CLI installed
  8. Docker installed
  9. Python 3+ installed

Deployment

  1. Clone the repository
git clone https://github.com/aws-samples/aws-genai-llm-chatbot
  1. Move into the cloned repository
cd aws-genai-llm-chatbot

(Optional) Only for Cloud9

If you use Cloud9, increase the instance's EBS volume to at least 100GB. To do this, run the following command from the Cloud9 terminal:

./scripts/cloud9-resize.sh

See the documentation for more details on environment resize.

  1. Install the project dependencies and build the project by running this command
npm install && npm run build
  1. Once done, run the magic-create CLI to help you set up the solution with the features you care most:
npm run create

You'll be prompted to configure the different aspects of the solution, such as:

  • The LLMs to enable (we support all models provided by Bedrock, FalconLite, LLama 2 and more to come)
  • Setup of the RAG system: engine selection (i.e. Aurora w/ pgvector, OpenSearch, Kendra..) embeddings selection and more to come.

When done, answer Y to create a new configuration.

sample

Your configuration is now stored under bin/config.json. You can re-run the magic-create command as needed to update your config.json

  1. (Optional) Bootstrap AWS CDK on the target account and region

Note: This is required if you have never used AWS CDK before on this account and region combination. (More information on CDK bootstrapping).

npx cdk bootstrap aws://{targetAccountId}/{targetRegion}

You can now deploy by running:

npx cdk deploy

Note: This step duration can vary greatly, depending on the Constructs you are deploying.

You can view the progress of your CDK deployment in the CloudFormation console in the selected region.

  1. Once deployed, take note of the User Interface, User Pool and, if you want to interact with 3P models providers, the Secret that will, eventually, hold the various API_KEYS should you want to experiment with 3P providers.
...
Outputs:
GenAIChatBotStack.UserInterfaceUserInterfaceDomanNameXXXXXXXX = dxxxxxxxxxxxxx.cloudfront.net
GenAIChatBotStack.AuthenticationUserPoolLinkXXXXX = https://xxxxx.console.aws.amazon.com/cognito/v2/idp/user-pools/xxxxx_XXXXX/users?region=xxxxx
GenAIChatBotStack.ApiKeysSecretNameXXXX = ApiKeysSecretName-xxxxxx
...
  1. Open the generated Cognito User Pool Link from outputs above i.e. https://xxxxx.console.aws.amazon.com/cognito/v2/idp/user-pools/xxxxx_XXXXX/users?region=xxxxx

  2. Add a user that will be used to log into the web interface.

  3. Open the User Interface Url for the outputs above, i.e. dxxxxxxxxxxxxx.cloudfront.net

  4. Login with the user created in .8; you will be asked to change the password.

Clean up

You can remove the stacks and all the associated resources created in your AWS account by running the following command:

npx cdk destroy

Authors

Credits

This sample was made possible thanks to the following libraries:

License

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

aws-genai-llm-chatbot's People

Contributors

bigadsoleiman avatar spugachev avatar massi-ang avatar amazon-auto avatar flolight avatar jingyan avatar vikramshitole avatar yarivlevy81 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.