This is a simple chatbot playground that uses the City of Boston's GenAI service to answer questions. It is built with the AWS CDK and uses cloud native GenAI services like Bedrock, OpenSearch and SageMaker.
This is a rebranding of the AWS GenAI Chatbot to be used by the City of Boston, with additional features and integrations.
This project is deployed using the AWS CDK. The cdk.json file tells the CDK how to deploy the stack. Below is a quick start guide to deploy the chatbot to your AWS account.
Remember to check this file for the latest instructions: docs/guide/deploy.md.
Verify that your environment satisfies the following prerequisites:
-
An AWS account
-
An IAM User with AdministratorAccess policy granted (for production, we recommend restricting access as needed)
-
NodeJS 18 or 20 installed
- If you are using
nvmyou can run the following before proceedingornvm install 18 && nvm use 18nvm install 20 && nvm use 20
- If you are using
-
AWS CLI installed and configured to use with your AWS account
-
AWS CDK CLI installed
-
Docker installed
- N.B.
buildxis also required. For Windows and macOSbuildxis included in Docker Desktop
- N.B.
-
Python 3+ installed
Step 1. Install the project dependencies and build the project.
npm ci && npm run buildStep 2. (Optional) Run the unit tests
npm run test && pip install -r pytest_requirements.txt && pytest testsStep 3. Once done, run the configuration command to help you set up the solution with the features you need:
npm run configYou'll be prompted to configure the different aspects of the solution, such as:
- The LLMs or MLMs to enable (we support all models provided by Bedrock that were enabled along with SageMaker hosted Idefics, FalconLite, Mistral and more to come).
- Setup of the RAG system: engine selection (i.e. Aurora w/ pgvector, OpenSearch, Kendra).
- Embeddings selection.
- Limit accessibility to website and backend to VPC (private chatbot).
- Add existing Amazon Kendra indices as RAG sources
*NOTE: In order to enable OIDC authentication, you must enter Y when prompted to enable advanced settings. You will find an option to enable OIDC authentication in the Cognito User Pool. A couple things to be aware of:
-
When you enable OIDC authentication, you will need to update the Cognito User Pool to include the
emailattribute and a customchatbot_roleattribute in the OIDC callback. In an organization, this would require you to liason with the identity provider team to get these attributes added to the OIDC callback. If this takes too long and you just want to get the chatbot up and running, you can remove the attribute mappings for all but the default 'username' attribute. This is done by commenting out the attribute mappings in thelib/authentication.tsfile. Doing this will require administrators to manually add users to the appropriate user groups based on thechatbot_roleattribute in the Cognito User Pool. Users' emails will also not show when they view their profile in the chatbot, but they will still be able to log in. -
By default, the cdk script will create a new cognito user pool, identity provider and cognito domain. Usually the identity provider team in an organization require a redirect URI to be set for the identity provider, which is the cognito domain with the path
/oauth2/idpresponse. If you don't want to change this every time you have a fresh deploy (if you already have a cognito user pool or cognito domain you'd like to use), you can set theexisting_cognito_user_poolandexisting_cognito_domainvariables to their corresponding values in thebin/config.jsonfile. Warning, this file is gitignored and partially overwritten each time you run thenpm run configcommand. -
If your OIDC provider requires custom endpoints, you can manually set the
OIDCAuthorizationEndpoint,OIDCJWKSURI,OIDCTokenEndpoint, andOIDCUserInfoEndpointvariables in thebin/config.jsonfile under thecognitoFederationobject.
For more details about the options, please refer to the configuration page
When done, answer Y to create or update your configuration.
Your configuration is now stored under bin/config.json. You can re-run the npm run config command as needed to update your config.json
Step 4. (Optional) Bootstrap AWS CDK on the target account and region
Note: This is required if you have never used AWS CDK on this account and region combination. (More information on CDK bootstrapping).
npm run cdk bootstrap aws://{targetAccountId}/{targetRegion}You can now deploy by running:
npm run cdk deployNote: 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.
npm ci && npm run build && npm run cdk deployThis library is licensed under the MIT-0 License. See the LICENSE file.
- Changelog of the project.
- License of the project.
- Code of Conduct of the project.
- CONTRIBUTING for more information.
Although this repository is released under the MIT-0 license, its front-end and SQL implementation use the following third party projects:
These projects' licensing includes the LGPL v3 and BlueOak-1.0.0 licenses.