Git Product home page Git Product logo

bedrock-claude-chat's Introduction

Bedrock Claude Chat

Warning The current version (v0.2.x) has no compatibility with ex version (v0.1.0) due to the change of the conversation schema. Please note that conversations stored in DynamoDB with ex version cannot be rendered.

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.

πŸ“š Supported Languages

  • English πŸ’¬
  • ζ—₯本θͺž πŸ’¬ (ドキγƒ₯γƒ‘γƒ³γƒˆγ―γ“γ‘γ‚‰)
  • ν•œκ΅­μ–΄ πŸ’¬
  • δΈ­ζ–‡ πŸ’¬

πŸš€ Super-easy Deployment

git clone https://github.com/aws-samples/bedrock-claude-chat.git
cd bedrock-claude-chat
chmod +x bin.sh
./bin.sh
  • After about 20 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.

Important This deployment method allows anyone with the URL to sign up. For production use, we strongly recommend adding IP address restrictions or disabling self-signup to mitigate security risks. To set up, Deploy using CDK for IP address restrictions or Disable self sign up.

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 and Roadmap

  • 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'
  • Streaming Response
  • IP address restriction
  • Edit message & re-send
  • I18n
  • Save and re-use prompt template

Deploy using CDK

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

  • Please have UNIX 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
cd cdk
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. Please replace your account id into <account id>.
cdk bootstrap aws://<account id>/us-east-1
  • If necessary, edit the following entries in cdk.json if necessary.

    • bedrockRegion: Region where Bedrock is available. NOTE: Bedrock does NOT support all regions for now.
    • allowedIpV4AddressRanges, allowedIpV6AddressRanges: Allowed IP Address range.
  • Deploy this sample project

cdk deploy --require-approval never --all
  • 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.6,
    "top_k": 250,
    "top_p": 0.999,
    "stop_sequences": ["Human: ", "Assistant: "],
}

Remove resources

If using cli and CDK, please cdk destroy. If not, access to CloudFormation then delete BedrockChatStack and FrontendWafStack manually. Please note that FrontendWafStack is on us-east-1 region.

Language Settings

This asset automatically detects the language using i18next-browser-languageDetector.You can switch languages from the application menu. Alternatively, you can use Query String to set the language as shown below.

https://example.com?lng=ja

Disable self sign up

This sample has self sign up enabled by default. To disable self sign up, open auth.ts and switch selfSignUpEnabled as false, then re-deploy.

const userPool = new UserPool(this, "UserPool", {
  passwordPolicy: {
    requireUppercase: true,
    requireSymbols: true,
    requireDigits: true,
    minLength: 8,
  },
  // true -> false
  selfSignUpEnabled: false,
  signInAliases: {
    username: false,
    email: true,
  },
});

Local Development

See LOCAL DEVELOPMENT.

Contribution

Thank you for considering contribution on this repository! We welcome for bug fixes, language translation, feature enhancements, and other improvements. Please see following:

RAG using Kendra

In this sample, we have not implemented RAG using Kendra. This is because when it comes to real-world deployments, factors such as access control policies, the presence or absence of data connectors, and the methods for authentication and authorization for the connected data sources can be quite diverse depending on the organization, making it difficult to generalize them in a simple manner. To put this into practice, you should consider downsides like decreased latency and increased token consumption. For these reasons, a proof of concept (PoC) to verify search accuracy is essential.

Authors

License

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

bedrock-claude-chat's People

Contributors

amazon-auto avatar dependabot[bot] avatar haven-king avatar mats16 avatar statefb avatar sugi275 avatar tmokmss avatar wadabee avatar wildgeece96 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.