Skip to content

Commit 1efd010

Browse files
mkhidir-awsgrinkocharles-marion
committed
feat: Add Application configuration
To use the project, Cognito user need a Cognito group (for example admin, user). Chatbot design was replaced to use CloudScape design pattern. - Support Amazon Nova LLMs Integration. - Add bedrock guardrails to all models in the langchain interface. - Add document support to chatbot sessions. - Add custom system prompts for non-bedrock models. - Add happy path selenium tests. - Update chatbot to use latest cloudscape components. - Create configurable applications with frontend implementation. - Bug fixes: - Fixed video understanding input. - Fixed integration tests following appsec findings. - Fixed input validation & presign URL role verification. - Fixed federation + application update. - Fixed RSS Feed, Application validation, RDS permissions. - Fixed semantic search validation. - Fixed import and unit test snapshots. - Security improvements: - Disabled Appsync introspection. - Updated security documentation. - Access control improvements: - Added access control to APIs. - Added unauthorized unit tests. - Implemented sendQuery access control. - Added role API. - Hide application attributes for non-admin users. Co-authored-by: Nikolai Grinko <[email protected]> Co-authored-by: Charles Marion <[email protected]>
1 parent 6117b0d commit 1efd010

File tree

213 files changed

+13325
-4689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+13325
-4689
lines changed

NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Author: Leonard Richardson
258258

259259
The following Python packages may be included in this product:
260260

261-
- numpy==1.26.0
261+
- numpy==1.26.4
262262

263263
These packages each contain the following license and notice below:
264264

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Deploying a Multi-Model and Multi-RAG Powered Chatbot Using AWS CDK on AWS
1+
# Building RAG use cases with GenAI Chatbot on AWS
22

33
[![Release Notes](https://img.shields.io/github/v/release/aws-samples/aws-genai-llm-chatbot)](https://github.com/aws-samples/aws-genai-llm-chatbot/releases)
44
[![GitHub star chart](https://img.shields.io/github/stars/aws-samples/aws-genai-llm-chatbot?style=social)](https://star-history.com/#aws-samples/aws-genai-llm-chatbot)
@@ -8,7 +8,7 @@
88

99
[![Full Documentation](https://img.shields.io/badge/Full%20Documentation-blue?style=for-the-badge&logo=Vite&logoColor=white)](https://aws-samples.github.io/aws-genai-llm-chatbot/)
1010

11-
![sample](docs/about/assets/chabot-sample.gif "AWS GenAI Chatbot")
11+
![sample](docs/about/assets/chabot-sample.gif "GenAI Chatbot on AWS")
1212

1313

1414
## 🚀 NEW! Support for new Amazon Nova Models 🚀
@@ -35,7 +35,7 @@ This solution provides ready-to-use code so you can start **experimenting with a
3535

3636
Supported model providers:
3737

38-
- [Amazon Bedrock](https://aws.amazon.com/bedrock/) which supports a wide range of models from AWS, Anthropic, Cohere and Mistral including the lastst models from Amazon Nova. See [Recent announcements](#) for more details.
38+
- [Amazon Bedrock](https://aws.amazon.com/bedrock/) which supports a wide range of models from AWS, Anthropic, Cohere and Mistral including the latest models from Amazon Nova. See [Recent announcements](https://aws.amazon.com/blogs/aws/introducing-amazon-nova-frontier-intelligence-and-industry-leading-price-performance/) for more details.
3939
- [Amazon SageMaker](https://aws.amazon.com/sagemaker/) self-hosted models from Foundation, Jumpstart and HuggingFace.
4040
- Third-party providers via API such as Anthropic, Cohere, AI21 Labs, OpenAI, etc. [See available langchain integrations](https://python.langchain.com/docs/integrations/llms/) for a comprehensive list.
4141

boto3-1.35.58-py3-none-any.whl

-136 KB
Binary file not shown.

botocore-1.35.58-py3-none-any.whl

-12.2 MB
Binary file not shown.

cli/magic-config.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ async function processCreateOptions(options: any): Promise<void> {
354354
{
355355
type: "confirm",
356356
name: "guardrailsEnable",
357-
message: "Do you want to enable Bedrock Guardrails",
357+
message:
358+
"Do you want to enable Bedrock Guardrails? This is a recommended feature to build responsible AI applications." +
359+
" (Supported by all models except Idefics via SageMaker. If enabled, streaming will only work with Bedrock)",
358360
initial: options.guardrailsEnable ?? false,
359361
},
360362
{
@@ -381,7 +383,7 @@ async function processCreateOptions(options: any): Promise<void> {
381383
{
382384
type: "confirm",
383385
name: "enableSagemakerModels",
384-
message: "Do you want to use any text generation Sagemaker Models",
386+
message: "Do you want to use any text generation SageMaker Models",
385387
initial: options.enableSagemakerModels || false,
386388
},
387389
{

docs/.vitepress/config.mts

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { defineConfig } from 'vitepress'
22

33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
5-
title: "AWS GenAI LLM Chatbot",
6-
description: "Deploying a Multi-Model and Multi-RAG Powered Chatbot Using AWS CDK on AWS",
5+
title: "GenAI Chatbot on AWS",
6+
description: "Building RAG use cases with GenAI Chatbot on AWS",
77
base: "/aws-genai-llm-chatbot/",
88
themeConfig: {
99
// https://vitepress.dev/reference/default-theme-config
@@ -44,13 +44,16 @@ export default defineConfig({
4444
text: 'Guide',
4545
items: [
4646
{ text: 'Deploy', link: '/guide/deploy' },
47+
{ text: 'Configuration', link: '/guide/config' },
4748
{ text: 'Developer Guide', link: '/guide/developers' },
4849
{ text: 'Development Prioritization', link: '/guide/prioritization' },
4950
]
5051
},
5152
{
5253
text: 'Documentation',
5354
items: [
55+
{ text: 'Access Control', link: '/documentation/access-control' },
56+
{ text: 'Applications', link: '/documentation/applications' },
5457
{ text: 'AppSync', link: '/documentation/appsync' },
5558
{ text: 'CloudFront Geo Restriction', link: '/documentation/cf-geo-restriction' },
5659
{
@@ -67,7 +70,7 @@ export default defineConfig({
6770
{ text: 'Precautions', link: '/documentation/precautions' },
6871
{ text: 'Private Chatbot', link: '/documentation/private-chatbot' },
6972
{ text: 'SageMaker Schedule', link: '/documentation/sagemaker-schedule' },
70-
{ text: 'Security', link: '/documentation/vulnerability-scanning' },
73+
{ text: 'Security', link: '/documentation/security' },
7174
{ text: 'Self-hosted models', link: '/documentation/self-hosted-models' },
7275
]
7376
}

docs/about/assets/application.gif

5.64 MB
Loading

docs/about/aws-resources-deployed.md

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Please note: This is list is considered a best effort approach to helping you un
1616
* **User Pool** [**Required**]
1717
* **User Pool Client** [**Required**]
1818
* Attach an existing Cognito Domain for Federation, adds Permission for User Pool to leverage existing Cognito Domain / Creates OIDC or SAML Identity Provider in Cognito [*Optional*]
19+
* **User Groups** [**Required**]
20+
* Admin and workspace_manager roles allow applications (configurable chatbots) and workspace management retrospectively.
1921

2022
## Retrieval Augmented Generation (RAG) Engines
2123
This section describes the RAG engines that house and return stored data for use with Generative AI. Additionally this section includes resources deployed to support data ingestion and processing for RAG.

docs/about/features.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Supported model providers:
1414

1515
Deploy [IDEFICS](https://huggingface.co/blog/idefics) models on [Amazon SageMaker](https://aws.amazon.com/sagemaker/) and see how the chatbot can answer questions about images, describe visual content, generate text grounded in multiple images.
1616

17-
![sample](./assets/multimodal-sample.gif "AWS GenAI Chatbot")
17+
![sample](./assets/multimodal-sample.gif "GenAI Chatbot on AWS")
1818

1919
Currently, the following multimodal models are supported:
2020

@@ -36,13 +36,13 @@ and select one of the supported models (press Space to select/deselect) from the
3636

3737
Send the same query to 2 to 4 separate models at once and see how each one responds based on its own learned history, context and access to the same powerful document retriever, so all requests can pull from the same up-to-date knowledge.
3838

39-
![sample](./assets/multichat-sample.gif "AWS GenAI Chatbot")
39+
![sample](./assets/multichat-sample.gif "GenAI Chatbot on AWS")
4040

4141
## Experiment with multiple RAG options with Workspaces
4242

4343
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.
4444

45-
![sample](./assets/create-workspace-sample.gif "AWS GenAI Chatbot")
45+
![sample](./assets/create-workspace-sample.gif "GenAI Chatbot on AWS")
4646

4747
## Unlock RAG potentials with Workspaces Debugging Tools
4848

@@ -52,7 +52,7 @@ The solution comes with several debugging tools to help you debug RAG scenarios:
5252
- Test different embeddings models directly in the UI
5353
- Test cross encoders and analyse distances from different functions between sentences.
5454

55-
![sample](./assets/workspace-debug-sample.gif "AWS GenAI Chatbot")
55+
![sample](./assets/workspace-debug-sample.gif "GenAI Chatbot on AWS")
5656

5757
## Full-fledged User Interface
5858

@@ -63,3 +63,11 @@ Protected with [Amazon Cognito Authentication](https://aws.amazon.com/cognito/)
6363
The interface layer between the UI and backend is built with [AppSync](https://docs.aws.amazon.com/appsync/latest/devguide/what-is-appsync.html) for management requests and for realtime interaction with chatbot (messages and responses) using GraphQL subscriptions.
6464

6565
Design system provided by [AWS Cloudscape Design System](https://cloudscape.design/).
66+
67+
## Configure and customize chatbots for different domains
68+
69+
The solution supports creating configurable chatbots called **applications**. Admin users can define applications by selecting a model, model settings, workspace, and system prompts. Configured applications are then available for regular users based on their assigned role, allowing controlled access to pre-configured chat experiences.
70+
71+
Roles determine which applications a user can access - for example, a "customer support" role may only be able to use applications tailored for handling support inquiries from users. Additional roles can be created as needed to cater applications to specific user groups or departments.
72+
73+
![sample](./assets/application.gif "GenAI Chatbot on AWS")

docs/about/welcome.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: doc
33
---
44

5-
# Deploying a Multi-Model and Multi-RAG Powered Chatbot Using AWS CDK on AWS
5+
# Building RAG use cases with GenAI Chatbot on AWS
66

77
[![Release Notes](https://img.shields.io/github/v/release/aws-samples/aws-genai-llm-chatbot)](https://github.com/aws-samples/aws-genai-llm-chatbot/releases)
88

@@ -12,9 +12,9 @@ layout: doc
1212

1313
[![Deploy with GitHub Codespaces](https://github.com/codespaces/badge.svg)](#deploy-with-github-codespaces)
1414

15-
The AWS GenAI LLM Chatbot provides ready-to-use code so you can start experimenting with a variety of Large Language Models and Multimodal Language Models, settings and prompts in your own AWS account.
15+
The GenAI Chatbot on AWS provides ready-to-use code so you can start experimenting with a variety of Large Language Models and Multimodal Language Models, settings and prompts in your own AWS account.
1616

17-
![sample](./assets/chabot-sample.gif "AWS GenAI Chatbot")
17+
![sample](./assets/chabot-sample.gif "GenAI Chatbot on AWS")
1818

1919
Want to find out more? Continue to [Features](./features).
2020

docs/documentation/access-control.md

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Access Control
2+
3+
**NOTE**
4+
5+
You need to assign the admin role to a user to be able to use the project after the first deployment revision with this feature. Users without a role will not be able to use the Chatbot.
6+
7+
8+
Users can have one or more roles defining their permissions. It can be used to restrict access to the functionalities as defined below.
9+
10+
11+
Rubicon has 3 pre-defined roles. They are created during deployment by CDK code.
12+
1. admin - _full access_
13+
2. workspace_manager - _full access except the admin pages such as managing applications_
14+
3. user - _access to assigned applications_
15+
16+
Instead of using pre-defined `user` role you can create new roles in Cognito and assign them to applications.
17+
18+
19+
## Create users and Roles
20+
21+
Users are created in Cognito user pool - [Create new users](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-create-user-accounts.html). If Cognito federation is used then users should be created in third-party identity provider. See [Cognito Federation](./cognito/overview.md) configuration examples.
22+
23+
User roles are defined using [Cognito user group](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-user-groups.html). When using federation with Cognito, the user's role is assigned on user log in reading the "custom:chatbot_role" user attribute.
24+
25+
26+
## Page Access by Role
27+
28+
* **admin**
29+
* ✅ Home (documentation)
30+
* ✅ Chatbot - Playground
31+
* ✅ Chatbot - Multi-chat playground
32+
* ✅ Chatbot - Sessions
33+
* ✅ Chatbot - Models
34+
* ✅ RAG - Dashboard
35+
* ✅ RAG - Semantic search
36+
* ✅ RAG - Workspaces
37+
* ✅ RAG - Embeddings
38+
* ✅ RAG - Engines
39+
* ✅ Admin - Applications
40+
* ✅ Applications - End user view
41+
42+
* **workspaces_manager**
43+
* ✅ Home (documentation)
44+
* ✅ Chatbot - Playground
45+
* ✅ Chatbot - Multi-chat playground
46+
* ✅ Chatbot - Sessions
47+
* ✅ Chatbot - Models
48+
* ✅ RAG - Dashboard
49+
* ✅ RAG - Semantic search
50+
* ✅ RAG - Workspaces
51+
* ✅ RAG - Embeddings
52+
* ✅ RAG - Engines
53+
* ⛔️ Admin - Applications
54+
* ✅ Applications - End user view
55+
56+
* **user**:
57+
It could be a role with any name which is associated with an application.
58+
* ⛔️ Home (documentation)
59+
* ⛔️ Chatbot - Playground
60+
* ⛔️ Chatbot - Multi-chat playground
61+
* ⛔️ Chatbot - Sessions
62+
* ⛔️ Chatbot - Models
63+
* ⛔️ RAG - Dashboard
64+
* ⛔️ RAG - Semantic search
65+
* ⛔️ RAG - Workspaces
66+
* ⛔️ RAG - Embeddings
67+
* ⛔️ RAG - Engines
68+
* ⛔️ Admin - Applications
69+
* ✅ Applications - End user view
70+
71+
72+
## GraphQL operations access by Role
73+
74+
* **Workspace**
75+
* createKendraWorkspace - _admin, workspace_manager_
76+
* startKendraDataSync - _admin, workspace_manager_
77+
* isKendraDataSynching - _admin, workspace_manager_
78+
* createBedrockKBWorkspace - _admin, workspace_manager_
79+
* createOpenSearchWorkspace - _admin, workspace_manager_
80+
* createAuroraWorkspace - _admin, workspace_manager_
81+
* performSemanticSearch - _admin, workspace_manager_
82+
* listWorkspaces - _admin, workspace_manager_
83+
* listKendraIndexes - _admin, workspace_manager_
84+
* listBedrockKnowledgeBases - _admin, workspace_manager_
85+
* listRagEngines - _admin, workspace_manager_
86+
* getWorkspace - _admin, workspace_manager_
87+
* deleteWorkspace - _admin, workspace_manager_
88+
89+
* **Document**
90+
* addWebsite - _admin, workspace_manager_
91+
* addRssFeed - _admin, workspace_manager_
92+
* updateRssFeed - _admin, workspace_manager_
93+
* setDocumentSubscriptionStatus - _admin, workspace_manager_
94+
* addQnADocument - _admin, workspace_manager_
95+
* addTextDocument - _admin, workspace_manager_
96+
* getUploadFileURL - _any authenticated user_
97+
* getDocument - _admin, workspace_manager_
98+
* getRSSPosts - _admin, workspace_manager_
99+
* listDocuments - _admin, workspace_manager_
100+
* deleteDocument - _admin, workspace_manager_
101+
102+
* **Session**
103+
* addUserFeedback - _any authenticated user_
104+
* deleteSession - _any authenticated user_
105+
* deleteUserSessions - _any authenticated user_
106+
* listSessions - _any authenticated user_
107+
* getSession - _any authenticated user_
108+
109+
* **Model**
110+
* listModels - _admin, workspace_manager_
111+
* listEmbeddingModels - _admin, workspace_manager_
112+
* listCrossEncoders - _admin, workspace_manager_
113+
* rankPassages - _admin, workspace_manager_
114+
* calculateEmbeddings - _admin, workspace_manager_
115+
* sendQuery - _any authenticated user_
116+
* receiveMessages - _any authenticated user_
117+
118+
* **Application**
119+
* createApplication - _admin_
120+
* updateApplication - _admin_
121+
* deleteApplication - _admin_
122+
* getApplication - _admin, workspace_manager, any other role that is assigned to the application_
123+
* listApplications - _admin, workspace_manager, any other role that is assigned to the application_
124+
125+
* **Role**
126+
* listRoles - _admin_
127+
128+
* **Internal**
129+
* publishResponse - _IAM Can only be called by the Lambda forwarding the chatbot responses_
130+
131+
* **Other**
132+
* checkHealth - _any authenticated user_

docs/documentation/applications.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Applications
2+
3+
An application is a pre-configured chatbot which could be embedded to a website. Admin users can define applications by selecting a model, model settings, workspace, and system prompts. Configured applications are then available for regular users based on their assigned role, allowing controlled access to pre-configured chat experiences.
4+
5+
Roles determine which applications a user can access - for example, a "customer support" role may only be able to use applications tailored for handling support inquiries from users. Admin and workspace_manager roles are created during deployment. Additional roles can be created by creating [Cognito groups](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-user-groups.html). Applications can then be assigned to one or more roles restricting what model and workspace an end user can use.
6+
7+
8+
## Application creation and usage
9+
![sample](../about/assets/application.gif "GenAI Chatbot on AWS")
10+
11+
12+
## Iframe integration
13+
1. Deploy Rubicon.
14+
2. Copy `GenAIChatBotStack.UserInterfaceUserInterfaceDomainName` value from the deployment output. It has `dxxxxxxxxxxxxx.cloudfront.net` format.
15+
3. Open UI dxxxxxxxxxxxxx.cloudfront.net.
16+
4. Create an application and open it (the URL will be used in the next step).
17+
5. Create an Iframe with the application URL as a source.
18+
19+
```html
20+
<!DOCTYPE html>
21+
<html>
22+
<head>
23+
<title>Chat Embed Test</title>
24+
</head>
25+
<body>
26+
<iframe
27+
src="https://dxxxxxxxxxxxxx.cloudfront.net/application/408a4758-018b-4147-ac76-ee9c169ba775"
28+
width="400"
29+
height="480"
30+
allow="microphone"
31+
style="border: 1px solid #ccc;"
32+
></iframe>
33+
</body>
34+
</html>
35+
```
36+
37+
### Example
38+
![Application](./assets/end-user-application.png "End-user chatbot")

docs/documentation/appsync.md

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
# Using AppSync
22

3-
Define or change the schema in `./lib/chatbot-api/schema`.
3+
The project relies on [AWS AppSync](https://docs.aws.amazon.com/appsync/latest/devguide/what-is-appsync.html) which creates serverless GraphQL and Pub/Sub APIs that simplify application development through a single endpoint to securely query, update, or publish data. One of the key advantages is [GraphQL subscriptions](https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-data.html) which is used to receive the chatbot responses in real time using streaming.
44

5-
At the moment we only use the `schema-ws.graphql` to define the real-time API. The REST API might be replaced by AppSync in the future.
5+
### Schema
6+
The GraphQL Schema defining the possible operatiosn can be found in `lib/chatbot-api/schema/schema.graphql`. Once deployed, AWS AppSync provides a Querying tool on the [AWS Console](https://us-east-1.console.aws.amazon.com/appsync/home?region=us-east-1) which can be used to explore and test the APIs.
67

7-
If you modified the definition for the schema, you can regenerate the client code using
8-
9-
```bash
10-
cd lib/user-interface/react-app
11-
npx @npx @aws-amplify/cli codegen add --apiId <api_id> --region <region>
12-
```
13-
14-
Accept all the defaults.
15-
16-
If you use a None data source, you need to modify `src/API.ts` adding:
17-
18-
```ts
19-
export type NoneQueryVariables = {
20-
none?: string | null;
21-
};
22-
```
8+
### Authentication
9+
AWS AppSync supports built in authentication modes. This project relies on the [@aws_cognito_user_pools one](https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html#using-additional-authorization-modes) to authenticate Amazon Cognito users.
Loading

0 commit comments

Comments
 (0)