Skip to content

Commit 256b58c

Browse files
Replace environment variables with service name for ChatQnA (#977)
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
1 parent 3c3a5be commit 256b58c

27 files changed

+330
-562
lines changed

ChatQnA/chatqna.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def generate_rag_prompt(question, documents):
3838
MEGA_SERVICE_HOST_IP = os.getenv("MEGA_SERVICE_HOST_IP", "0.0.0.0")
3939
MEGA_SERVICE_PORT = int(os.getenv("MEGA_SERVICE_PORT", 8888))
4040
GUARDRAIL_SERVICE_HOST_IP = os.getenv("GUARDRAIL_SERVICE_HOST_IP", "0.0.0.0")
41-
GUARDRAIL_SERVICE_PORT = int(os.getenv("GUARDRAIL_SERVICE_PORT", 9090))
41+
GUARDRAIL_SERVICE_PORT = int(os.getenv("GUARDRAIL_SERVICE_PORT", 80))
4242
EMBEDDING_SERVER_HOST_IP = os.getenv("EMBEDDING_SERVER_HOST_IP", "0.0.0.0")
43-
EMBEDDING_SERVER_PORT = int(os.getenv("EMBEDDING_SERVER_PORT", 6006))
43+
EMBEDDING_SERVER_PORT = int(os.getenv("EMBEDDING_SERVER_PORT", 80))
4444
RETRIEVER_SERVICE_HOST_IP = os.getenv("RETRIEVER_SERVICE_HOST_IP", "0.0.0.0")
4545
RETRIEVER_SERVICE_PORT = int(os.getenv("RETRIEVER_SERVICE_PORT", 7000))
4646
RERANK_SERVER_HOST_IP = os.getenv("RERANK_SERVER_HOST_IP", "0.0.0.0")
47-
RERANK_SERVER_PORT = int(os.getenv("RERANK_SERVER_PORT", 8808))
47+
RERANK_SERVER_PORT = int(os.getenv("RERANK_SERVER_PORT", 80))
4848
LLM_SERVER_HOST_IP = os.getenv("LLM_SERVER_HOST_IP", "0.0.0.0")
49-
LLM_SERVER_PORT = int(os.getenv("LLM_SERVER_PORT", 9009))
49+
LLM_SERVER_PORT = int(os.getenv("LLM_SERVER_PORT", 80))
5050

5151

5252
def align_inputs(self, inputs, cur_node, runtime_graph, llm_parameters_dict, **kwargs):

ChatQnA/docker_compose/intel/cpu/aipc/README.md

Lines changed: 30 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,42 @@ Run the command to download LLM models. The <host_ip> is the one set in [Ollama
6161
```
6262
export host_ip=<host_ip>
6363
export OLLAMA_HOST=http://${host_ip}:11434
64-
ollama pull llama3
64+
ollama pull llama3.2
6565
```
6666

6767
After downloaded the models, you can list the models by `ollama list`.
6868

6969
The output should be similar to the following:
7070

7171
```
72-
NAME ID SIZE MODIFIED
73-
llama3:latest 365c0bd3c000 4.7 GB 5 days ago
72+
NAME ID SIZE MODIFIED
73+
llama3.2:latest a80c4f17acd5 2.0 GB 2 minutes ago
7474
```
7575

7676
### Consume Ollama LLM Service
7777

7878
Access ollama service to verify that the ollama is functioning correctly.
7979

8080
```bash
81-
curl http://${host_ip}:11434/api/generate -d '{"model": "llama3", "prompt":"What is Deep Learning?"}'
81+
curl http://${host_ip}:11434/api/generate -d '{"model": "llama3.2", "prompt":"What is Deep Learning?"}'
8282
```
8383

8484
The outputs are similar to these:
8585

8686
```
87-
{"model":"llama3","created_at":"2024-10-11T07:58:38.949268562Z","response":"Deep","done":false}
88-
{"model":"llama3","created_at":"2024-10-11T07:58:39.017625351Z","response":" learning","done":false}
89-
{"model":"llama3","created_at":"2024-10-11T07:58:39.102848076Z","response":" is","done":false}
90-
{"model":"llama3","created_at":"2024-10-11T07:58:39.171037991Z","response":" a","done":false}
91-
{"model":"llama3","created_at":"2024-10-11T07:58:39.243757952Z","response":" subset","done":false}
92-
{"model":"llama3","created_at":"2024-10-11T07:58:39.328708084Z","response":" of","done":false}
93-
{"model":"llama3","created_at":"2024-10-11T07:58:39.413844974Z","response":" machine","done":false}
94-
{"model":"llama3","created_at":"2024-10-11T07:58:39.486239329Z","response":" learning","done":false}
95-
{"model":"llama3","created_at":"2024-10-11T07:58:39.555960842Z","response":" that","done":false}
96-
{"model":"llama3","created_at":"2024-10-11T07:58:39.642418238Z","response":" involves","done":false}
97-
{"model":"llama3","created_at":"2024-10-11T07:58:39.714137478Z","response":" the","done":false}
98-
{"model":"llama3","created_at":"2024-10-11T07:58:39.798776679Z","response":" use","done":false}
99-
{"model":"llama3","created_at":"2024-10-11T07:58:39.883747938Z","response":" of","done":false}
87+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.098813868Z","response":"Deep","done":false}
88+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.124514468Z","response":" learning","done":false}
89+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.149754216Z","response":" is","done":false}
90+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.180420784Z","response":" a","done":false}
91+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.229185873Z","response":" subset","done":false}
92+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.263956118Z","response":" of","done":false}
93+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.289097354Z","response":" machine","done":false}
94+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.316838918Z","response":" learning","done":false}
95+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.342309506Z","response":" that","done":false}
96+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.367221264Z","response":" involves","done":false}
97+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.39205893Z","response":" the","done":false}
98+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.417933974Z","response":" use","done":false}
99+
{"model":"llama3.2","created_at":"2024-10-12T12:55:28.443110388Z","response":" of","done":false}
100100
...
101101
```
102102

@@ -155,13 +155,21 @@ cd ~/OPEA/GenAIExamples/ChatQnA/ui
155155
docker build --no-cache -t opea/chatqna-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
156156
```
157157

158-
Then run the command `docker images`, you will have the following 5 Docker Images:
158+
### 6. Build Nginx Docker Image
159+
160+
```bash
161+
cd GenAIComps
162+
docker build -t opea/nginx:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/nginx/Dockerfile .
163+
```
164+
165+
Then run the command `docker images`, you will have the following 6 Docker Images:
159166

160167
1. `opea/dataprep-redis:latest`
161168
2. `opea/retriever-redis:latest`
162169
3. `opea/llm-ollama:latest`
163170
4. `opea/chatqna:latest`
164171
5. `opea/chatqna-ui:latest`
172+
6. `opea/nginx:latest`
165173

166174
## 🚀 Start Microservices
167175

@@ -201,55 +209,21 @@ export http_proxy=${your_http_proxy}
201209
export https_proxy=${your_http_proxy}
202210
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
203211
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
204-
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:6006"
205-
export REDIS_URL="redis://${host_ip}:6379"
206212
export INDEX_NAME="rag-redis"
207213
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
208-
export MEGA_SERVICE_HOST_IP=${host_ip}
209-
export EMBEDDING_SERVER_HOST_IP=${host_ip}
210-
export RETRIEVER_SERVICE_HOST_IP=${host_ip}
211-
export RERANK_SERVER_HOST_IP=${host_ip}
212-
export LLM_SERVER_HOST_IP=${host_ip}
213-
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/chatqna"
214-
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6007/v1/dataprep"
215-
export DATAPREP_GET_FILE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/get_file"
216-
export DATAPREP_DELETE_FILE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/delete_file"
217-
export FRONTEND_SERVICE_IP=${host_ip}
218-
export FRONTEND_SERVICE_PORT=5173
219-
export BACKEND_SERVICE_NAME=chatqna
220-
export BACKEND_SERVICE_IP=${host_ip}
221-
export BACKEND_SERVICE_PORT=8888
222-
223214
export OLLAMA_ENDPOINT=http://${host_ip}:11434
224-
export OLLAMA_MODEL="llama3"
215+
export OLLAMA_MODEL="llama3.2"
225216
```
226217

227218
- Windows PC
228219

229220
```bash
230221
set EMBEDDING_MODEL_ID=BAAI/bge-base-en-v1.5
231222
set RERANK_MODEL_ID=BAAI/bge-reranker-base
232-
set TEI_EMBEDDING_ENDPOINT=http://%host_ip%:6006
233-
set REDIS_URL=redis://%host_ip%:6379
234223
set INDEX_NAME=rag-redis
235224
set HUGGINGFACEHUB_API_TOKEN=%your_hf_api_token%
236-
set MEGA_SERVICE_HOST_IP=%host_ip%
237-
set EMBEDDING_SERVER_HOST_IP=%host_ip%
238-
set RETRIEVER_SERVICE_HOST_IP=%host_ip%
239-
set RERANK_SERVER_HOST_IP=%host_ip%
240-
set LLM_SERVER_HOST_IP=%host_ip%
241-
set BACKEND_SERVICE_ENDPOINT=http://%host_ip%:8888/v1/chatqna
242-
set DATAPREP_SERVICE_ENDPOINT=http://%host_ip%:6007/v1/dataprep
243-
set DATAPREP_GET_FILE_ENDPOINT="http://%host_ip%:6007/v1/dataprep/get_file"
244-
set DATAPREP_DELETE_FILE_ENDPOINT="http://%host_ip%:6007/v1/dataprep/delete_file"
245-
set FRONTEND_SERVICE_IP=%host_ip%
246-
set FRONTEND_SERVICE_PORT=5173
247-
set BACKEND_SERVICE_NAME=chatqna
248-
set BACKEND_SERVICE_IP=%host_ip%
249-
set BACKEND_SERVICE_PORT=8888
250-
251225
set OLLAMA_ENDPOINT=http://host.docker.internal:11434
252-
set OLLAMA_MODEL="llama3"
226+
set OLLAMA_MODEL="llama3.2"
253227
```
254228

255229
Note: Please replace with `host_ip` with you external IP address, do not use localhost.
@@ -263,15 +237,6 @@ cd ~/OPEA/GenAIExamples/ChatQnA/docker_compose/intel/cpu/aipc/
263237
docker compose up -d
264238
```
265239

266-
Let ollama service runs (if you have started ollama service in [Prerequisites](#Prerequisites), skip this step)
267-
268-
```bash
269-
# e.g. ollama run llama3
270-
OLLAMA_HOST=${host_ip}:11434 ollama run $OLLAMA_MODEL
271-
# for windows
272-
# ollama run %OLLAMA_MODEL%
273-
```
274-
275240
### Validate Microservices
276241

277242
Follow the instructions to validate MicroServices.
@@ -309,7 +274,7 @@ For details on how to verify the correctness of the response, refer to [how-to-v
309274
4. Ollama Service
310275

311276
```bash
312-
curl http://${host_ip}:11434/api/generate -d '{"model": "llama3", "prompt":"What is Deep Learning?"}'
277+
curl http://${host_ip}:11434/api/generate -d '{"model": "llama3.2", "prompt":"What is Deep Learning?"}'
313278
```
314279

315280
5. LLM Microservice
@@ -325,7 +290,7 @@ For details on how to verify the correctness of the response, refer to [how-to-v
325290

326291
```bash
327292
curl http://${host_ip}:8888/v1/chatqna -H "Content-Type: application/json" -d '{
328-
"messages": "What is the revenue of Nike in 2023?", "model": "'"${OLLAMA_MODEL}"'"
293+
"messages": "What is the revenue of Nike in 2023?"
329294
}'
330295
```
331296

ChatQnA/docker_compose/intel/cpu/aipc/compose.yaml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ services:
1313
container_name: dataprep-redis-server
1414
depends_on:
1515
- redis-vector-db
16+
- tei-embedding-service
1617
ports:
1718
- "6007:6007"
1819
environment:
1920
no_proxy: ${no_proxy}
2021
http_proxy: ${http_proxy}
2122
https_proxy: ${https_proxy}
22-
REDIS_URL: ${REDIS_URL}
23+
REDIS_URL: redis://redis-vector-db:6379
24+
REDIS_HOST: redis-vector-db
2325
INDEX_NAME: ${INDEX_NAME}
24-
TEI_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
26+
TEI_ENDPOINT: http://tei-embedding-service:80
2527
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
2628
tei-embedding-service:
2729
image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.5
@@ -48,9 +50,10 @@ services:
4850
no_proxy: ${no_proxy}
4951
http_proxy: ${http_proxy}
5052
https_proxy: ${https_proxy}
51-
REDIS_URL: ${REDIS_URL}
53+
REDIS_URL: redis://redis-vector-db:6379
54+
REDIS_HOST: redis-vector-db
5255
INDEX_NAME: ${INDEX_NAME}
53-
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
56+
TEI_EMBEDDING_ENDPOINT: http://tei-embedding-service:80
5457
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
5558
restart: unless-stopped
5659
tei-reranking-service:
@@ -79,7 +82,6 @@ services:
7982
no_proxy: ${no_proxy}
8083
http_proxy: ${http_proxy}
8184
https_proxy: ${https_proxy}
82-
TGI_LLM_ENDPOINT: ${TGI_LLM_ENDPOINT}
8385
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
8486
HF_HUB_DISABLE_PROGRESS_BARS: 1
8587
HF_HUB_ENABLE_HF_TRANSFER: 0
@@ -90,6 +92,7 @@ services:
9092
container_name: chatqna-aipc-backend-server
9193
depends_on:
9294
- redis-vector-db
95+
- dataprep-redis-service
9396
- tei-embedding-service
9497
- retriever
9598
- tei-reranking-service
@@ -100,14 +103,14 @@ services:
100103
- no_proxy=${no_proxy}
101104
- https_proxy=${https_proxy}
102105
- http_proxy=${http_proxy}
103-
- MEGA_SERVICE_HOST_IP=${MEGA_SERVICE_HOST_IP}
104-
- EMBEDDING_SERVER_HOST_IP=${EMBEDDING_SERVICE_HOST_IP}
105-
- EMBEDDING_SERVER_PORT=${EMBEDDING_SERVICE_PORT:-6006}
106-
- RETRIEVER_SERVICE_HOST_IP=${RETRIEVER_SERVICE_HOST_IP}
107-
- RERANK_SERVER_HOST_IP=${RERANK_SERVICE_HOST_IP}
108-
- RERANK_SERVER_PORT=${RERANK_SERVICE_PORT:-8808}
109-
- LLM_SERVER_HOST_IP=${LLM_SERVICE_HOST_IP}
110-
- LLM_SERVER_PORT=${LLM_SERVICE_PORT:-9000}
106+
- MEGA_SERVICE_HOST_IP=chaqna-aipc-backend-server
107+
- EMBEDDING_SERVER_HOST_IP=tei-embedding-service
108+
- EMBEDDING_SERVER_PORT=80
109+
- RETRIEVER_SERVICE_HOST_IP=retriever
110+
- RERANK_SERVER_HOST_IP=tei-reranking-service
111+
- RERANK_SERVER_PORT=80
112+
- LLM_SERVER_HOST_IP=llm
113+
- LLM_SERVER_PORT=9000
111114
- LOGFLAG=${LOGFLAG}
112115
ipc: host
113116
restart: always
@@ -122,10 +125,6 @@ services:
122125
- no_proxy=${no_proxy}
123126
- https_proxy=${https_proxy}
124127
- http_proxy=${http_proxy}
125-
- CHAT_BASE_URL=${BACKEND_SERVICE_ENDPOINT}
126-
- UPLOAD_FILE_BASE_URL=${DATAPREP_SERVICE_ENDPOINT}
127-
- GET_FILE=${DATAPREP_GET_FILE_ENDPOINT}
128-
- DELETE_FILE=${DATAPREP_DELETE_FILE_ENDPOINT}
129128
ipc: host
130129
restart: always
131130
chaqna-aipc-nginx-server:
@@ -140,11 +139,13 @@ services:
140139
- no_proxy=${no_proxy}
141140
- https_proxy=${https_proxy}
142141
- http_proxy=${http_proxy}
143-
- FRONTEND_SERVICE_IP=${FRONTEND_SERVICE_IP}
144-
- FRONTEND_SERVICE_PORT=${FRONTEND_SERVICE_PORT}
145-
- BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
146-
- BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
147-
- BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
142+
- FRONTEND_SERVICE_IP=chatqna-xeon-ui-server
143+
- FRONTEND_SERVICE_PORT=5173
144+
- BACKEND_SERVICE_NAME=chatqna
145+
- BACKEND_SERVICE_IP=chatqna-xeon-backend-server
146+
- BACKEND_SERVICE_PORT=8888
147+
- DATAPREP_SERVICE_IP=dataprep-redis-service
148+
- DATAPREP_SERVICE_PORT=6007
148149
ipc: host
149150
restart: always
150151

ChatQnA/docker_compose/intel/cpu/aipc/set_env.sh

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,6 @@ fi
1515
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
1616
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
1717
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
18-
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:6006"
19-
export TEI_RERANKING_ENDPOINT="http://${host_ip}:8808"
20-
export REDIS_URL="redis://${host_ip}:6379"
2118
export INDEX_NAME="rag-redis"
22-
export REDIS_HOST=${host_ip}
23-
export MEGA_SERVICE_HOST_IP=${host_ip}
24-
export EMBEDDING_SERVICE_HOST_IP=${host_ip}
25-
export RETRIEVER_SERVICE_HOST_IP=${host_ip}
26-
export RERANK_SERVICE_HOST_IP=${host_ip}
27-
export LLM_SERVICE_HOST_IP=${host_ip}
28-
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/chatqna"
29-
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6007/v1/dataprep"
30-
export DATAPREP_GET_FILE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/get_file"
31-
export DATAPREP_DELETE_FILE_ENDPOINT="http://${host_ip}:6007/v1/dataprep/delete_file"
32-
export FRONTEND_SERVICE_IP=${host_ip}
33-
export FRONTEND_SERVICE_PORT=5173
34-
export BACKEND_SERVICE_NAME=chatqna
35-
export BACKEND_SERVICE_IP=${host_ip}
36-
export BACKEND_SERVICE_PORT=8888
37-
3819
export OLLAMA_ENDPOINT=http://${host_ip}:11434
39-
export OLLAMA_MODEL="llama3"
20+
export OLLAMA_MODEL="llama3.2"

ChatQnA/docker_compose/intel/cpu/xeon/README_qdrant.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,20 @@ docker build --no-cache -t opea/chatqna-conversation-ui:latest --build-arg https
118118
cd ../../../..
119119
```
120120

121-
Then run the command `docker images`, you will have the following 4 Docker Images:
121+
### 6. Build Nginx Docker Image
122+
123+
```bash
124+
cd GenAIComps
125+
docker build -t opea/nginx:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/nginx/Dockerfile .
126+
```
127+
128+
Then run the command `docker images`, you will have the following 5 Docker Images:
122129

123130
1. `opea/dataprep-qdrant:latest`
124131
2. `opea/retriever-qdrant:latest`
125132
3. `opea/chatqna:latest`
126133
4. `opea/chatqna-ui:latest`
134+
5. `opea/nginx:latest`
127135

128136
## 🚀 Start Microservices
129137

@@ -172,18 +180,7 @@ export https_proxy=${your_http_proxy}
172180
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
173181
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
174182
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
175-
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:6040"
176-
export QDRANT_HOST=${host_ip}
177-
export QDRANT_PORT=6333
178183
export INDEX_NAME="rag-qdrant"
179-
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
180-
export EMBEDDING_SERVER_HOST_IP=${host_ip}
181-
export MEGA_SERVICE_HOST_IP=${host_ip}
182-
export RETRIEVER_SERVICE_HOST_IP=${host_ip}
183-
export RERANK_SERVER_HOST_IP=${host_ip}
184-
export LLM_SERVER_HOST_IP=${host_ip}
185-
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8912/v1/chatqna"
186-
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6043/v1/dataprep"
187184
```
188185

189186
Note: Please replace with `host_ip` with you external IP address, do not use localhost.

0 commit comments

Comments
 (0)