Skip to content

Commit 5cc3b38

Browse files
authored
Porting HybridRAG to Text2Query microservice (#2293)
Signed-off-by: Yi Yao <yi.a.yao@intel.com>
1 parent cb4a12a commit 5cc3b38

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

HybridRAG/docker_compose/intel/hpu/gaudi/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ The HybridRAG docker images should automatically be downloaded from the `OPEA re
4747

4848
```
4949
[+] Running 9/9
50-
✔ Container redis-vector-db Healthy 6.4s
51-
✔ Container vllm-service Started 0.4s
52-
✔ Container tei-embedding-server Started 0.9s
53-
✔ Container neo4j-apoc Healthy 11.4s
54-
✔ Container tei-reranking-server Started 0.8s
55-
✔ Container retriever-redis-server Started 1.0s
56-
✔ Container dataprep-redis-server Started 6.5s
57-
✔ Container text2cypher-gaudi-container Started 12.2s
58-
✔ Container hybridrag-xeon-backend-server Started 12.4s
50+
✔ Container redis-vector-db Healthy 6.4s
51+
✔ Container vllm-service Started 0.4s
52+
✔ Container tei-embedding-server Started 0.9s
53+
✔ Container neo4j-apoc Healthy 11.4s
54+
✔ Container tei-reranking-server Started 0.8s
55+
✔ Container retriever-redis-server Started 1.0s
56+
✔ Container dataprep-redis-server Started 6.5s
57+
✔ Container text2query-cypher-gaudi-container Started 12.2s
58+
✔ Container hybridrag-xeon-backend-server Started 12.4s
5959
```
6060

6161
To rebuild the docker image for the hybridrag-xeon-backend-server container:
@@ -78,7 +78,7 @@ For the default deployment, the following 10 containers should have started:
7878
```
7979
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8080
a9286abd0015 opea/hybridrag:latest "python hybridrag.py" 15 hours ago Up 15 hours 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp hybridrag-xeon-backend-server
81-
8477b154dc72 opea/text2cypher-gaudi:latest "/bin/sh -c 'bash ru…" 15 hours ago Up 15 hours 0.0.0.0:11801->9097/tcp, [::]:11801->9097/tcp text2cypher-gaudi-container
81+
8477b154dc72 opea/text2query-cypher:latest "/bin/sh -c 'bash ru…" 15 hours ago Up 15 hours 0.0.0.0:11801->9097/tcp, [::]:11801->9097/tcp text2query-cypher-gaudi-container
8282
688e01a431fa opea/dataprep:latest "sh -c 'python $( [ …" 15 hours ago Up 15 hours 0.0.0.0:6007->5000/tcp, [::]:6007->5000/tcp dataprep-redis-server
8383
54f574fe54bb opea/retriever:latest "python opea_retriev…" 15 hours ago Up 15 hours 0.0.0.0:7000->7000/tcp, :::7000->7000/tcp retriever-redis-server
8484
5028eb66617c ghcr.io/huggingface/text-embeddings-inference:cpu-1.6 "text-embeddings-rou…" 15 hours ago Up 15 hours 0.0.0.0:8808->80/tcp, [::]:8808->80/tcp tei-reranking-server

HybridRAG/docker_compose/intel/hpu/gaudi/compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
services:
55
text2cypher-gaudi:
6-
image: ${REGISTRY:-opea}/text2cypher-gaudi:${TAG:-latest}
7-
container_name: text2cypher-gaudi-container
6+
image: ${REGISTRY:-opea}/text2query-cypher:${TAG:-latest}
7+
container_name: text2query-cypher-gaudi-container
88
ports:
99
- "11801:9097"
1010
depends_on:
@@ -26,6 +26,7 @@ services:
2626
NEO4J_USERNAME: ${NEO4J_USERNAME}
2727
NEO4J_PASSWORD: ${NEO4J_PASSWORD}
2828
host_ip: ${host_ip}
29+
TEXT2QUERY_COMPONENT_NAME: "OPEA_TEXT2QUERY_CYPHER"
2930
runtime: habana
3031
cap_add:
3132
- SYS_NICE

HybridRAG/docker_image_build/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ services:
1313
context: ../
1414
dockerfile: ./Dockerfile
1515
image: ${REGISTRY:-opea}/hybridrag:${TAG:-latest}
16-
text2cypher-gaudi:
16+
text2query-cypher:
1717
build:
1818
context: GenAIComps
19-
dockerfile: comps/text2cypher/src/Dockerfile.intel_hpu
19+
dockerfile: comps/text2query/src/Dockerfile.cypher.intel_hpu
2020
extends: hybridrag
21-
image: ${REGISTRY:-opea}/text2cypher-gaudi:${TAG:-latest}
21+
image: ${REGISTRY:-opea}/text2query-cypher:${TAG:-latest}
2222
dataprep:
2323
build:
2424
context: GenAIComps

HybridRAG/hybridrag.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ def __init__(self, host="0.0.0.0", port=8000):
255255
self.endpoint = str(MegaServiceEndpoint.HYBRID_RAG)
256256

257257
async def exec_text2cypher(self, prompt):
258-
url = f"http://{TEXT2CYPHER_SERVER_HOST_IP}:{TEXT2CYPHER_SERVER_PORT}/v1/text2cypher"
258+
url = f"http://{TEXT2CYPHER_SERVER_HOST_IP}:{TEXT2CYPHER_SERVER_PORT}/v1/text2query"
259259
headers = {"Content-Type": "application/json"}
260260
if refresh_db == "False":
261-
data = {"input_text": prompt, "seeding": {"refresh_db": "False"}}
261+
data = {"query": prompt, "options": {"refresh_db": "False"}}
262262
elif cypher_insert is not None:
263-
data = {"input_text": prompt, "seeding": {"cypher_insert": "'${cypher_insert}'", "refresh_db": "True"}}
263+
data = {"query": prompt, "options": {"cypher_insert": "'${cypher_insert}'", "refresh_db": "True"}}
264264
else:
265-
data = {"input_text": prompt}
265+
data = {"query": prompt}
266266
response = requests.post(url, json=data)
267267
data = response.json()
268268
data_str = str(data)
@@ -295,12 +295,12 @@ def add_remote_service(self):
295295
)
296296

297297
text2cypher = MicroService(
298-
name="text2cypher",
298+
name="text2query",
299299
host=TEXT2CYPHER_SERVER_HOST_IP,
300300
port=TEXT2CYPHER_SERVER_PORT,
301-
endpoint="/text2cypher",
301+
endpoint="/text2query",
302302
use_remote_service=True,
303-
service_type=ServiceType.TEXT2CYPHER,
303+
service_type=ServiceType.TEXT2QUERY,
304304
)
305305

306306
retriever = MicroService(

HybridRAG/tests/test_compose_on_gaudi.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function build_docker_images() {
2828
popd && sleep 1s
2929

3030
echo "Build all the images with --no-cache, check docker_image_build.log for details..."
31-
service_list="hybridrag hybridrag-ui dataprep retriever text2cypher-gaudi nginx"
31+
service_list="hybridrag hybridrag-ui dataprep retriever text2query-cypher nginx"
3232
docker compose -f build.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log 2>&1
3333

3434
docker images && sleep 1s
@@ -72,9 +72,9 @@ function validate_service() {
7272

7373
local HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "$INPUT_DATA" -H 'Content-Type: application/json' "$URL")
7474

75-
if [ "$DOCKER_NAME" = "text2cypher-gaudi-container" ]; then
75+
if [ "$DOCKER_NAME" = "text2query-cypher-gaudi-container" ]; then
7676
docker ps
77-
docker logs text2cypher-gaudi-container
77+
docker logs text2query-cypher-gaudi-container
7878
fi
7979

8080
if [ "$HTTP_STATUS" -eq 200 ]; then
@@ -89,7 +89,7 @@ function validate_service() {
8989
docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
9090
if [ "$DOCKER_NAME" = "hybridrag-xeon-backend-server" ]; then
9191
docker ps
92-
docker logs text2cypher-gaudi-container
92+
docker logs text2query-cypher-gaudi-container
9393
fi
9494
exit 1
9595
fi
@@ -98,7 +98,7 @@ function validate_service() {
9898
docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
9999
if [ "$DOCKER_NAME" = "hybridrag-xeon-backend-server" ]; then
100100
docker ps
101-
docker logs text2cypher-gaudi-container
101+
docker logs text2query-cypher-gaudi-container
102102
fi
103103
exit 1
104104
fi
@@ -156,13 +156,13 @@ function validate_megaservice() {
156156
}
157157

158158
function validate_text2cypher() {
159-
# text2cypher service
159+
# text2query-cypher service
160160
validate_service \
161-
"${ip_address}:11801/v1/text2cypher" \
161+
"${ip_address}:11801/v1/text2query" \
162162
"\[" \
163163
"text2cypher-gaudi" \
164-
"text2cypher-gaudi-container" \
165-
'{"input_text": "what are the symptoms for Diabetes?"}'
164+
"text2query-cypher-gaudi-container" \
165+
'{"query": "what are the symptoms for Diabetes?"}'
166166
}
167167

168168
function stop_docker() {

0 commit comments

Comments
 (0)