@@ -52,6 +52,7 @@ function start_services() {
52
52
export TEI_RERANKING_ENDPOINT=" http://${ip_address} :8808"
53
53
export TGI_LLM_ENDPOINT=" http://${ip_address} :8008"
54
54
export REDIS_URL=" redis://${ip_address} :6379"
55
+ export REDIS_HOST=${ip_address}
55
56
export INDEX_NAME=" rag-redis"
56
57
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
57
58
export MEGA_SERVICE_HOST_IP=${ip_address}
@@ -61,6 +62,8 @@ function start_services() {
61
62
export LLM_SERVICE_HOST_IP=${ip_address}
62
63
export BACKEND_SERVICE_ENDPOINT=" http://${ip_address} :8888/v1/chatqna"
63
64
export DATAPREP_SERVICE_ENDPOINT=" http://${ip_address} :6007/v1/dataprep"
65
+ export DATAPREP_GET_FILE_ENDPOINT=" http://${ip_address} :6008/v1/dataprep/get_file"
66
+ export DATAPREP_DELETE_FILE_ENDPOINT=" http://${ip_address} :6009/v1/dataprep/delete_file"
64
67
65
68
sed -i " s/backend_address/$ip_address /g" $WORKPATH /docker/ui/svelte/.env
66
69
@@ -93,104 +96,147 @@ function start_services() {
93
96
done
94
97
}
95
98
96
- function validate_services () {
99
+ function validate_service () {
97
100
local URL=" $1 "
98
101
local EXPECTED_RESULT=" $2 "
99
102
local SERVICE_NAME=" $3 "
100
103
local DOCKER_NAME=" $4 "
101
104
local INPUT_DATA=" $5 "
102
105
103
- local HTTP_STATUS=$( curl -s -o /dev/null -w " %{http_code}" -X POST -d " $INPUT_DATA " -H ' Content-Type: application/json' " $URL " )
104
- if [ " $HTTP_STATUS " -eq 200 ]; then
105
- echo " [ $SERVICE_NAME ] HTTP status is 200. Checking content..."
106
+ if [[ $SERVICE_NAME == * " dataprep_upload_file" * ]]; then
107
+ cd $LOG_PATH
108
+ HTTP_RESPONSE=$( curl --silent --write-out " HTTPSTATUS:%{http_code}" -X POST -F ' files=@./dataprep_file.txt' -H ' Content-Type: multipart/form-data' " $URL " )
109
+ elif [[ $SERVICE_NAME == * " dataprep_upload_link" * ]]; then
110
+ HTTP_RESPONSE=$( curl --silent --write-out " HTTPSTATUS:%{http_code}" -X POST -F ' link_list=["https://www.ces.tech/"]' " $URL " )
111
+ elif [[ $SERVICE_NAME == * " dataprep_get" * ]]; then
112
+ HTTP_RESPONSE=$( curl --silent --write-out " HTTPSTATUS:%{http_code}" -X POST -H ' Content-Type: application/json' " $URL " )
113
+ elif [[ $SERVICE_NAME == * " dataprep_del" * ]]; then
114
+ HTTP_RESPONSE=$( curl --silent --write-out " HTTPSTATUS:%{http_code}" -X POST -d ' {"file_path": "all"}' -H ' Content-Type: application/json' " $URL " )
115
+ else
116
+ HTTP_RESPONSE=$( curl --silent --write-out " HTTPSTATUS:%{http_code}" -X POST -d " $INPUT_DATA " -H ' Content-Type: application/json' " $URL " )
117
+ fi
118
+ HTTP_STATUS=$( echo $HTTP_RESPONSE | tr -d ' \n' | sed -e ' s/.*HTTPSTATUS://' )
119
+ RESPONSE_BODY=$( echo $HTTP_RESPONSE | sed -e ' s/HTTPSTATUS\:.*//g' )
106
120
107
- local CONTENT= $( curl -s -X POST -d " $INPUT_DATA " -H ' Content-Type: application/json ' " $URL " | tee $ {LOG_PATH} /${SERVICE_NAME} .log)
121
+ docker logs ${DOCKER_NAME} >> $ {LOG_PATH} /${SERVICE_NAME} .log
108
122
109
- if echo " $CONTENT " | grep -q " $EXPECTED_RESULT " ; then
110
- echo " [ $SERVICE_NAME ] Content is as expected."
111
- else
112
- echo " [ $SERVICE_NAME ] Content does not match the expected result: $CONTENT "
113
- docker logs ${DOCKER_NAME} >> ${LOG_PATH} /${SERVICE_NAME} .log
114
- exit 1
115
- fi
116
- else
123
+ # check response status
124
+ if [ " $HTTP_STATUS " -ne " 200" ]; then
117
125
echo " [ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS "
118
- docker logs ${DOCKER_NAME} >> ${LOG_PATH} /${SERVICE_NAME} .log
119
126
exit 1
127
+ else
128
+ echo " [ $SERVICE_NAME ] HTTP status is 200. Checking content..."
129
+ fi
130
+ # check response body
131
+ if [[ " $RESPONSE_BODY " != * " $EXPECTED_RESULT " * ]]; then
132
+ echo " [ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY "
133
+ exit 1
134
+ else
135
+ echo " [ $SERVICE_NAME ] Content is as expected."
120
136
fi
137
+
121
138
sleep 1s
122
139
}
123
140
124
141
function validate_microservices() {
125
142
# Check if the microservices are running correctly.
126
143
127
144
# tei for embedding service
128
- validate_services \
145
+ validate_service \
129
146
" ${ip_address} :8090/embed" \
130
- " \[\ [" \
147
+ " [ [" \
131
148
" tei-embedding" \
132
149
" tei-embedding-gaudi-server" \
133
150
' {"inputs":"What is Deep Learning?"}'
134
151
135
152
# embedding microservice
136
- validate_services \
153
+ validate_service \
137
154
" ${ip_address} :6000/v1/embeddings" \
138
- ' "text":"What is Deep Learning?","embedding":\ [' \
139
- " embedding" \
155
+ ' "text":"What is Deep Learning?","embedding":[' \
156
+ " embedding-microservice " \
140
157
" embedding-tei-server" \
141
158
' {"text":"What is Deep Learning?"}'
142
159
143
160
sleep 1m # retrieval can't curl as expected, try to wait for more time
144
161
162
+ # test /v1/dataprep upload file
163
+ echo " Deep learning is a subset of machine learning that utilizes neural networks with multiple layers to analyze various levels of abstract data representations. It enables computers to identify patterns and make decisions with minimal human intervention by learning from large amounts of data." > $LOG_PATH /dataprep_file.txt
164
+ validate_service \
165
+ " http://${ip_address} :6007/v1/dataprep" \
166
+ " Data preparation succeeded" \
167
+ " dataprep_upload_file" \
168
+ " dataprep-redis-server"
169
+
170
+ # test /v1/dataprep upload link
171
+ validate_service \
172
+ " http://${ip_address} :6007/v1/dataprep" \
173
+ " Data preparation succeeded" \
174
+ " dataprep_upload_link" \
175
+ " dataprep-redis-server"
176
+
177
+ # test /v1/dataprep/get_file
178
+ validate_service \
179
+ " http://${ip_address} :6008/v1/dataprep/get_file" \
180
+ ' {"name":' \
181
+ " dataprep_get" \
182
+ " dataprep-redis-server"
183
+
184
+ # test /v1/dataprep/delete_file
185
+ validate_service \
186
+ " http://${ip_address} :6009/v1/dataprep/delete_file" \
187
+ ' {"status":true}' \
188
+ " dataprep_del" \
189
+ " dataprep-redis-server"
190
+
145
191
# retrieval microservice
146
192
test_embedding=$( python3 -c " import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)" )
147
- validate_services \
193
+ validate_service \
148
194
" ${ip_address} :7000/v1/retrieval" \
149
- " " \
150
- " retrieval" \
195
+ " retrieved_docs " \
196
+ " retrieval-microservice " \
151
197
" retriever-redis-server" \
152
198
" {\" text\" :\" What is the revenue of Nike in 2023?\" ,\" embedding\" :${test_embedding} }"
153
199
154
200
# tei for rerank microservice
155
- validate_services \
201
+ validate_service \
156
202
" ${ip_address} :8808/rerank" \
157
203
' {"index":1,"score":' \
158
204
" tei-rerank" \
159
205
" tei-reranking-gaudi-server" \
160
206
' {"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."]}'
161
207
162
208
# rerank microservice
163
- validate_services \
209
+ validate_service \
164
210
" ${ip_address} :8000/v1/reranking" \
165
211
" Deep learning is..." \
166
- " rerank" \
212
+ " rerank-microservice " \
167
213
" reranking-tei-gaudi-server" \
168
214
' {"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}]}'
169
215
170
216
# tgi for llm service
171
- validate_services \
217
+ validate_service \
172
218
" ${ip_address} :8008/generate" \
173
219
" generated_text" \
174
220
" tgi-llm" \
175
221
" tgi-gaudi-server" \
176
222
' {"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":17, "do_sample": true}}'
177
223
178
224
# llm microservice
179
- validate_services \
225
+ validate_service \
180
226
" ${ip_address} :9000/v1/chat/completions" \
181
227
" data: " \
182
- " llm" \
228
+ " llm-microservice " \
183
229
" llm-tgi-gaudi-server" \
184
230
' {"query":"What is Deep Learning?"}'
185
231
186
232
}
187
233
188
234
function validate_megaservice() {
189
235
# Curl the Mega Service
190
- validate_services \
236
+ validate_service \
191
237
" ${ip_address} :8888/v1/chatqna" \
192
- " billion " \
193
- " mega- chatqna" \
238
+ " data: " \
239
+ " chatqna-megaservice " \
194
240
" chatqna-gaudi-backend-server" \
195
241
' {"messages": "What is the revenue of Nike in 2023?"}'
196
242
@@ -241,7 +287,7 @@ function main() {
241
287
elif [ " ${mode} " == " " ]; then
242
288
validate_microservices
243
289
validate_megaservice
244
- # validate_frontend
290
+ validate_frontend
245
291
fi
246
292
247
293
stop_docker
0 commit comments