Skip to content

Commit beb9e62

Browse files
committed
Fixed cluster connection string
1 parent 34d1512 commit beb9e62

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

webinars/genai-chatbot/.DS_Store

8 KB
Binary file not shown.

webinars/genai-chatbot/README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,85 @@
11
# Build a generative AI Virtual Assistant with [Amazon Bedrock](https://aws.amazon.com/bedrock/), [Langchain](https://github.com/langchain-ai/langchain) and [Amazon Elasticache](https://aws.amazon.com/elasticache/)
22

3-
In this 15-minute session [YouTube video](https://www.youtube.com/watch?v=yWxDmQYelvg), we will discuss how you can use [Amazon Bedrock](https://aws.amazon.com/bedrock/), [Langchain](https://github.com/langchain-ai/langchain) and [Amazon Elasticache](https://aws.amazon.com/elasticache/) services together to implement a generative AI (GenAI) chatbot. We will dive into two application patterns: they are chat history and messaging broker patterns. We will show you how ElastiCache for Redis simplifies the implementation of these application patterns by leveraging the built-in Redis data structures.
4-
5-
ElastiCache is a fully managed, Redis- and Memcached-compatible service delivering real-time, cost-optimized performance for modern applications.
3+
In this 15-minute session [YouTube video](https://www.youtube.com/watch?v=yWxDmQYelvg), we will discuss how you can use [Amazon Bedrock](https://aws.amazon.com/bedrock/), [Langchain](https://github.com/langchain-ai/langchain) and [Amazon Elasticache](https://aws.amazon.com/elasticache/) services together to implement a generative AI (GenAI) chatbot. We will dive into two application patterns: they are chat history and messaging broker patterns. We will show you how ElastiCache simplifies the implementation of these application patterns by leveraging the built-in Redis data structures.
64

5+
ElastiCache is a fully managed service delivering real-time, cost-optimized performance for modern applications.
76
ElastiCache scales to hundreds of millions operations per second with microsecond response time, and offers enterprise-grade security and reliability.
8-
97
## Chatbot Application Deployment
108

119
This guide will walk you through the steps to deploy a Python chatbot application using [Streamlit](https://github.com/streamlit/streamlit) on [Cloud9](https://aws.amazon.com/cloud9/). This is the architecture we will be implementing today.
1210

11+
1312
![Architecture Diagram](./images/arch.png)
1413

15-
The application is contained in the `chatbot_app.py` file, and it requires specific packages listed in `requirements.txt`.
14+
15+
The application is contained in the 'chatbot_app.py' file, and it requires specific packages listed in 'requirements.txt'.
1616

1717
## Prerequisites
1818

19+
1920
Before you proceed, make sure you have the following prerequisites in place:
2021

2122
1. An AWS Cloud9 development environment set up.
23+
2224
2. We will be using [Amazon Bedrock](https://aws.amazon.com/bedrock/) to access foundation models in this workshop.
23-
3. Enable Foundation models such as Claude, as shown below:
2425

26+
3. Enable Foundation models such as Claude, as shown below:
2527
![Bedrock Model](./images/model-access-edit.png)
2628

2729
4. Python and pip installed in your Cloud9 environment.
28-
5. Internet connectivity to download packages.
2930

30-
## Installation
3131

32+
## Installation
3233
1. Clone this repository to your Cloud9 environment:
3334

3435
```bash
35-
git clone [your-repo-url]
36-
cd chatbot-app
36+
git clone https://github.com/aws-samples/amazon-elasticache-samples.git
37+
```
38+
39+
```
40+
cd webinars/genai-chatbot
3741
```
38-
42+
3943
2. Install the required packages using pip:
4044

4145
```bash
42-
pip3 install -r ~/environment/workshop/setup/requirements.txt -U
46+
pip3 install -r ~/environment/workshop/setup/requirements.txt -U
4347
```
4448

45-
3. Configure environment variables.
49+
3. Set the ElastiCache cluster endpoint as below. Use redis instead of rediss it encryption is not enabled.
4650

51+
```bash
52+
export ELASTICACHE_ENDPOINT_URL=rediss://ClusterURL:6379
53+
```
4754

48-
4. You can run the following commands to confirm:
49-
(check [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html))
55+
## Running the Application
5056

5157
```bash
52-
echo $BWB_ENDPOINT_URL
53-
echo $BWB_PROFILE_NAME
54-
echo $BWB_REGION_NAME
58+
streamlit run 'chatbot_app.py' --server.port 8080
5559
```
5660

61+
## Testing the chat history with ElastiCache
5762

58-
## Running the Application
63+
The first step is to login to the application. This would create a unique session to be stored in Amazon ElastiCache. This session data is retrieved, summarized and provided as a context to the LLM to help stay in context.
64+
65+
![Login](./images/model-access-edit.png)
5966

67+
Here are some sample questions you can try out to validate the LLM stays in context while loading previous conversation from Elasticache.
68+
69+
1. Can you help me draft a 4 sentence email to highlight some fun upcoming events for my employees?
70+
71+
2. Can you add in these events into the email: 1. Internal networking event on 4/20/2024, Summer gift giveaway on 6/20/2024, 3. End of summer picnic: 8/15/2024, 4. Fall Formal on 10/10/2024, and 5. Christmas Party on 12/18/2024
72+
73+
3. Can you reformat it with bullets for my events?
74+
75+
4. Can you please remove everything that happens after September 2024
76+
77+
Here is how we can check the session data stored in ElastiCache.
6078
```bash
61-
streamlit run chatbot_app.py --server.port 8080
62-
```
79+
redis-cli -c --user $ECUserName --askpass -h $ELASTICACHE_ENDPOINT_UR --tls
80+
81+
```
6382

83+
```
84+
LRANGE "chat_history:user1" 0 -1
85+
```
17.9 KB
Loading

0 commit comments

Comments
 (0)