Skip to content

Commit e8d1570

Browse files
Improve LLM doc chat user exp (#9)
* cleanup notebook and dependencies * updates to readme and structure * pin openai SDK version
1 parent cc769fe commit e8d1570

10 files changed

+780
-991
lines changed

.env.template

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1+
# General OpenAI Env Vars
12
OPENAI_TEXT_MODEL=gpt-35-turbo
2-
OPENAI_DEPLOYMENT_TYPE=Text
33
OPENAI_EMBEDDING_MODEL=text-embedding-ada-002
4-
OPENAI_EMBEDDINGS_ENGINE_QUERY=text-embedding-ada-002
5-
OPENAI_API_KEY=<your key here>
6-
# use OPENAI_API_VERSION only with Azure OpenAI
7-
#OPENAI_API_VERSION=2023-05-15
84
OPENAI_TEMPERATURE=0.7
95
OPENAI_MAX_TOKENS=50
10-
CHUNK_SIZE=500
11-
CHUNK_OVERLAP=0.2
6+
7+
# OpenAI Direct Env Vars
8+
OPENAI_API_KEY=<your key here>
9+
OPENAI_API_BASE=https://api.openai.com/v1/
10+
11+
# Azure OpenAI Env Vars
12+
#OPENAI_API_VERSION=2023-05-15 # use OPENAI_API_VERSION only with Azure OpenAI
1213
AZURE_EMBED_MODEL_DEPLOYMENT_NAME=<your deployment name here>
1314
AZURE_TEXT_MODEL_DEPLOYMENT_NAME=<your deployment name here>
1415
AZURE_OPENAI_API_BASE=https://<your deployment name>.openai.azure.com/
15-
OPENAI_API_BASE=https://api.openai.com/v1/
16-
REDIS_ADDRESS=redis
17-
REDIS_PORT=6379
18-
REDIS_PASSWORD=
1916

17+
# General Env Vars
18+
CHUNK_SIZE=500
19+
CHUNK_OVERLAP=0.2
20+
21+
# Redis Env Vars
22+
REDIS_HOST=redis
23+
REDIS_PORT=6379
24+
REDIS_PASSWORD=

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ docker-compose-keys.yml
33
.env
44
.env-azure
55
.env-azure-local
6-
.env-openai
6+
.env-openai
7+
.local
8+
.cache
9+
.jupyter
10+
.ipython
11+
.npm

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Redis Ventures
3+
Copyright (c) 2023 Redis Inc
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+62-33
Original file line numberDiff line numberDiff line change
@@ -6,83 +6,112 @@ and provide a chatbot-like experience using OpenAI.
66
https://user-images.githubusercontent.com/13009163/237002719-26e3118d-77ee-4ded-96f5-6ba801cae66c.mov
77

88

9-
## Setting up the Environment
9+
## Getting Started
1010

11-
The tutorial can run in multiple ways. The first step is to configure the ``.env`` file in this repository. This file contains the following variables:
11+
The LLM Document Chat tutorial is **intended to run on a dockerized Jupyter lab environment** to ensure ideal experience and minimal Python environment hickups. At a minimum, you will need to install [Docker Desktop](https://www.docker.com/products/docker-desktop/) (*which comes with Docker Compose*) to run this example.
12+
13+
The project maintains a `.env.template` with the following variables pre-defined:
1214

1315
```bash
14-
OPENAI_TEXT_MODEL=text-davinci-003
15-
OPENAI_DEPLOYMENT_TYPE=Text
16+
# General OpenAI Env Vars
17+
OPENAI_TEXT_MODEL=gpt-35-turbo
1618
OPENAI_EMBEDDING_MODEL=text-embedding-ada-002
17-
OPENAI_EMBEDDINGS_ENGINE_QUERY=text-embedding-ada-002
18-
OPENAI_API_KEY=<your key here>
1919
OPENAI_TEMPERATURE=0.7
2020
OPENAI_MAX_TOKENS=50
21-
CHUNK_SIZE=500
22-
CHUNK_OVERLAP=100
21+
22+
# OpenAI Direct Env Vars
23+
OPENAI_API_KEY=<your key here>
24+
OPENAI_API_BASE=https://api.openai.com/v1/
25+
26+
# Azure OpenAI Env Vars
27+
#OPENAI_API_VERSION=2023-05-15 # use OPENAI_API_VERSION only with Azure OpenAI
2328
AZURE_EMBED_MODEL_DEPLOYMENT_NAME=<your deployment name here>
2429
AZURE_TEXT_MODEL_DEPLOYMENT_NAME=<your deployment name here>
2530
AZURE_OPENAI_API_BASE=https://<your deployment name>.openai.azure.com/
26-
OPENAI_API_BASE=https://api.openai.com/v1/
27-
REDIS_ADDRESS=localhost
31+
32+
# General Env Vars
33+
CHUNK_SIZE=500
34+
CHUNK_OVERLAP=0.2
35+
36+
# Redis Env Vars
37+
REDIS_HOST=redis
2838
REDIS_PORT=6379
2939
REDIS_PASSWORD=
3040
```
3141

32-
### To Use Azure OpenAI
42+
Make a copy of this file to create `.env` as follows:
43+
```bash
44+
$ cp .env.template .env
45+
```
46+
47+
Update portions of the env file based on your choices below:
48+
1. **[Choose your OpenAI provider](#choose-your-openai-provider)**
49+
2. **[Choose your Redis provider](#choose-your-redis-provider)**
50+
3351

52+
### Choose your OpenAI provider
53+
You can choose between **[Azure OpenAI Service](#to-use-azure-openai)** (fully hosted and managed by Azure) and **[OpenAI](#to-use-openai)** direct.
54+
55+
56+
#### To Use Azure OpenAI (Recommended)
3457
To use Azure OpenAI, you will need to follow these instructions
3558

36-
1. Create an Azure OpenAI resource
37-
2. Create model deployments for the text and embedding models
38-
4. Configure the ``.env`` file adding the specific values for your deployments
59+
1. Create an Azure OpenAI resource.
60+
2. Create model deployments for the text and embedding models.
61+
4. Configure the ``.env`` file adding the specific values for your deployments.
3962

4063
```bash
4164
AZURE_EMBED_MODEL_DEPLOYMENT_NAME=<your deployment name here>
4265
AZURE_TEXT_MODEL_DEPLOYMENT_NAME=<your deployment name here>
4366
AZURE_OPENAI_API_BASE=https://<your deployment name>.openai.azure.com/
4467
```
4568

46-
### To Use OpenAI
69+
#### To Use OpenAI
4770

4871
To use OpenAI, you will need to follow these instructions
4972

50-
1. Create an OpenAI account
51-
2. Create an OpenAI API key
52-
3. Configure the ``.env`` file adding the specific values for your deployments
73+
1. Create an OpenAI account.
74+
2. Create an OpenAI API key.
75+
3. Configure the ``.env`` file adding the specific values for your deployments.
5376

5477
```bash
5578
OPENAI_API_KEY=<your key here>
5679
```
5780

5881

59-
### Azure Redis Enterprise, Redis Enterprise Cloud, and Redis Stack
82+
### Choose your Redis provider
83+
The tutorial will require the usage of the Redis Search & Query features, including support for Vector Similarity Search. There are three options for running Redis:
6084

61-
The tutorial will require the usage of the Redis-stack container because of the use of RediSearch
62-
and RedisJSON. There are three options for Redis
63-
64-
1. Redis Enterprise Cloud
85+
1. [Redis Enterprise Cloud - Free Instance](https://redis.com/try-free)
6586
2. Azure Redis Enterprise (ACRE)
66-
3. Redis Stack (docker)
67-
4. Redis Stack (local)
87+
3. Redis Stack (local docker)
6888

69-
For each, the following options are required
89+
For each, the following options are **required** and must be updated in your local `.env` file:
7090

7191
```bash
7292
REDIS_PASSWORD=<your password here>
73-
REDIS_ADDRESS=<your redis address here>
93+
REDIS_HOST=<your redis host address here>
7494
REDIS_PORT=<your redis port here>
7595
```
7696

7797
There are some ``docker-compose.yml`` files in the ``docker`` directory that will help spin up
7898
redis-stack locally and redisinsight in the case where a remote Redis is being used (like ACRE).
7999

80-
### Run
81-
100+
## Run
82101

83-
To run the script, follow these steps:
102+
To open the jupyter environment through docker, follow these steps:
84103

85104
1. Clone this repository to your local machine.
86-
2. copy the ``.env.template`` to ``.env`` and configure the values as outlined above.
87-
3. If using a local Python environment, just run the notebook
88-
3. Otherwise, select a docker-compose file to run and execute ``docker-compose up`` to start the environment.
105+
2. Copy the ``.env.template`` to ``.env`` and configure the values as outlined above.
106+
3. Run with Docker Compose:
107+
108+
**For Cloud or Azure Redis Enterprise**
109+
```bash
110+
docker compose -f docker/cloud/docker-compose.yml up
111+
```
112+
113+
**For Local (Docker) Redis Stack**
114+
```bash
115+
docker compose -f docker/local/docker-compose.yml up
116+
```
117+
4. Open the Jupyter lab session in your browser at `http://127.0.0.1:8888/lab?token={YOUR GENERATED TOKEN}`. *Check the terminal logs for the token string.*

docker/azure/docker-compose.yml renamed to docker/cloud/docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
container_name: jupyter
1212
volumes:
1313
- ../../:/home/jovyan/
14+
env_file:
15+
- ../../.env
1416
ports:
1517
- 8888:8888
1618
depends_on:

docker/local/docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919
container_name: jupyter
2020
volumes:
2121
- ../../:/home/jovyan/
22+
env_file:
23+
- ../../.env
2224
ports:
2325
- 8888:8888
2426
depends_on:

0 commit comments

Comments
 (0)