Skip to content

koga-lvgs/bedrock-claude-chat

 
 

Repository files navigation

Bedrock Claude Chat

日本語はこちら

This repository is a sample chatbot using the Anthropic company's LLM Claude 2, one of the foundational models provided by Amazon Bedrock for generative AI. As of August 2023, Bedrock is under preview, and applications are required for usage. This sample is currently developed for use by Japanese speakers, but it is also possible to speak to the chatbot in English.

Architecture

It's an architecture built on AWS managed services, eliminating the need for infrastructure management. Utilizing Amazon Bedrock, there's no need to communicate with APIs outside of AWS. This enables deploying scalable, reliable, and secure applications.

Features

  • Authentication (Sign-up, Sign-in)
  • Creation, storage, and deletion of conversations
  • Copying of chatbot replies
  • Automatic subject suggestion for conversations
  • Syntax highlighting for code
  • Rendering of Markdown

Deployment

Prerequisites

  • As of August 2023, Bedrock is under preview, and applications are required for usage.

🚀 Easy Deployment

git clone https://github.com/aws-samples/bedrock-claude-chat.git
  • Run deployment via following commands
cd bedrock-claude-chat
chmod +x bin.sh
./bin.sh
  • After about 10 minutes, you will get the following output, which you can access from your browser
Frontend URL: https://xxxxxxxxx.cloudfront.net

The sign-up screen will appear as shown above, where you can register your email and log in.

Deploy using CDK

Easy Deployment uses AWS CodeBuild to perform deployment by CDK internally. This section describes the procedure for deploying directly with CDK.

  • Please have UNIX commands and a Node.js runtime environment. If not, you can also use Cloud9
  • Clone this repository
git clone https://github.com/aws-samples/bedrock-claude-chat
  • Install npm packages
cd bedrock-claude-chat
npm ci
npm i -g aws-cdk
  • Before deploying the CDK, you will need to work with Bootstrap once for the region you are deploying to. In this example, we will deploy to the us-east-1 region
cd cdk
cdk bootstrap us-east-1
  • If necessary, edit the following entries in [cdk.json](. /cdk/cdk.json) if necessary.

    • bedrockRegion: Region where Bedrock is available.
    • bedrockEndpointUrl: URL of the Bedrock endpoint.
  • Deploy this sample project

cdk deploy --require-approval never
  • You will get output similar to the following. The URL of the web app will be output in BedrockChatStack.FrontendURL, so please access it from your browser.
 ✅  BedrockChatStack

✨  Deployment time: 78.57s

Outputs:
BedrockChatStack.AuthUserPoolClientIdXXXXX = xxxxxxx
BedrockChatStack.AuthUserPoolIdXXXXXX = ap-northeast-1_XXXX
BedrockChatStack.BackendApiBackendApiUrlXXXXX = https://xxxxx.execute-api.ap-northeast-1.amazonaws.com
BedrockChatStack.FrontendURL = https://xxxxx.cloudfront.net

Others

Configure text generation parameters

Edit config.py and run cdk deploy.

GENERATION_CONFIG = {
    "max_tokens_to_sample": 500,
    "temperature": 0.0,
    "top_k": 250,
    "top_p": 0.999,
    "stop_sequences": ["Human: ", "Assistant: "],
}

Authors

About

AWS-native chatbot using Bedrock + Claude 2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 59.4%
  • Python 34.2%
  • JavaScript 2.4%
  • Shell 2.3%
  • Dockerfile 0.7%
  • HTML 0.7%
  • CSS 0.3%