From c23f83af4a61c3ca496b69b2c24622001e9a054d Mon Sep 17 00:00:00 2001 From: zepan Date: Tue, 13 Aug 2024 01:09:24 +0800 Subject: [PATCH] Fix issue for reranking-langchain-mosec. Signed-off-by: zepan --- .../langchain-mosec/mosec-docker/Dockerfile | 4 ++-- .../langchain-mosec/mosec-docker/server-ipex.py | 2 +- tests/test_reranks_langchain-mosec.sh | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/comps/reranks/langchain-mosec/mosec-docker/Dockerfile b/comps/reranks/langchain-mosec/mosec-docker/Dockerfile index 8fca32833..dcf38aee5 100644 --- a/comps/reranks/langchain-mosec/mosec-docker/Dockerfile +++ b/comps/reranks/langchain-mosec/mosec-docker/Dockerfile @@ -12,14 +12,14 @@ ENV GLIBC_TUNABLES glibc.cpu.x86_shstk=permissive COPY comps /home/user/comps RUN apt update && apt install -y python3 python3-pip -USER user + RUN pip3 install torch==2.2.2 torchvision --trusted-host download.pytorch.org --index-url https://download.pytorch.org/whl/cpu RUN pip3 install intel-extension-for-pytorch==2.2.0 RUN pip3 install transformers sentence-transformers RUN pip3 install llmspec mosec RUN cd /home/user/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-reranker-large --local-dir /home/user/bge-reranker-large - +USER user ENV EMB_MODEL="/home/user/bge-reranker-large/" WORKDIR /home/user/comps/reranks/langchain-mosec/mosec-docker diff --git a/comps/reranks/langchain-mosec/mosec-docker/server-ipex.py b/comps/reranks/langchain-mosec/mosec-docker/server-ipex.py index cd81fbf33..c7127c6ea 100644 --- a/comps/reranks/langchain-mosec/mosec-docker/server-ipex.py +++ b/comps/reranks/langchain-mosec/mosec-docker/server-ipex.py @@ -16,7 +16,7 @@ from torch.utils.data import DataLoader from tqdm.autonotebook import tqdm, trange -DEFAULT_MODEL = "/root/bge-reranker-large" +DEFAULT_MODEL = "/home/user/bge-reranker-large" class MyCrossEncoder(CrossEncoder): diff --git a/tests/test_reranks_langchain-mosec.sh b/tests/test_reranks_langchain-mosec.sh index 118466667..0d43ffeee 100644 --- a/tests/test_reranks_langchain-mosec.sh +++ b/tests/test_reranks_langchain-mosec.sh @@ -31,19 +31,19 @@ function start_service() { } function validate_microservice() { - mosec_service_port=5007 - HTTP_STATUS=$(http_proxy="" curl -w "%{http_code}" http://${ip_address}:${mosec_service_port}/v1/reranking\ + mosec_service_port=5002 + result=$(http_proxy="" curl http://${ip_address}:$mosec_service_port/v1/embeddings \ -X POST \ - -d '{"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}]}' \ + -d '{"text":"What is Deep Learning?"}' \ -H 'Content-Type: application/json') - if [ "$HTTP_STATUS" -eq 200 ]; then - echo "Result correct. HTTP status is 200." + if [[ $result == *"Human"* ]]; then + echo "Result correct." else - echo "Result wrong. HTTP status is not 200. Received status was $HTTP_STATUS" - docker logs test-comps-reranking-langchain-mosec-server + echo "Result wrong. Received was $result" docker logs test-comps-reranking-langchain-mosec-endpoint + docker logs test-comps-reranking-langchain-mosec-server exit 1 - fi + fi } function stop_docker() {