Add docker for ChatQnA Mega Service on Xeon (#136)
Signed-off-by: letonghan <letong.han@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -17,8 +17,6 @@ First of all, you need to build Docker Images locally and install the python pac
|
||||
```bash
|
||||
git clone https://github.com/opea-project/GenAIComps.git
|
||||
cd GenAIComps
|
||||
pip install -r requirements.txt
|
||||
pip install .
|
||||
```
|
||||
|
||||
### 1. Build Embedding Image
|
||||
@@ -148,7 +146,7 @@ curl http://${host_ip}:9009/generate \
|
||||
```bash
|
||||
curl http://${host_ip}:9000/v1/chat/completions\
|
||||
-X POST \
|
||||
-d '{"text":"What is Deep Learning?"}' \
|
||||
-d '{"query":"What is Deep Learning?","max_new_tokens":17,"top_k":10,"top_p":0.95,"typical_p":0.95,"temperature":0.01,"repetition_penalty":1.03,"streaming":true}' \
|
||||
-H 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
@@ -160,6 +158,29 @@ Modify the `initial_inputs` of line 34 in `chatqna.py`, then you will get the Ch
|
||||
|
||||
All of the intermediate results will be printed for each microservices. Users can check the accuracy of the results to make targeted modifications.
|
||||
|
||||
### Run Mega Service with Python
|
||||
|
||||
```bash
|
||||
# install packages
|
||||
cd /GenAIComps
|
||||
pip install -r requirements.txt
|
||||
pip install .
|
||||
# run chatqna service
|
||||
cd /GenAIExamples/ChatQnA/microservice/xeon
|
||||
python chatqna.py
|
||||
```
|
||||
|
||||
### Run Mega Service with Docker
|
||||
|
||||
To run ChatQnA service with Docker, remember to pass the `${micro_service_host_ip}` variable into docker container, which is the real host ip of your microservices.
|
||||
|
||||
```bash
|
||||
docker build -t opea/gen-ai-comps:chatqna-xeon-server --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f docker/Dockerfile .
|
||||
docker run -d --name="chatqna-xeon-server" -p 8888:8888 --ipc=host -e https_proxy=$https_proxy -e http_proxy=$http_proxy -e SERVICE_SERVICE_HOST_IP=${micro_service_host_ip} opea/gen-ai-comps:chatqna-xeon-server
|
||||
```
|
||||
|
||||
Then you can check the result of your chatqna service with the command below.
|
||||
|
||||
```bash
|
||||
docker logs chatqna-xeon-server
|
||||
```
|
||||
|
||||
@@ -13,8 +13,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import os
|
||||
|
||||
from comps import MicroService, ServiceOrchestrator
|
||||
|
||||
SERVICE_HOST_IP = os.getenv("SERVICE_SERVICE_HOST_IP", "0.0.0.0")
|
||||
|
||||
|
||||
class ChatQnAService:
|
||||
def __init__(self, port=8000):
|
||||
@@ -22,16 +26,16 @@ class ChatQnAService:
|
||||
|
||||
def add_remote_service(self):
|
||||
embedding = MicroService(
|
||||
name="embedding", host="0.0.0.0", port=6000, expose_endpoint="/v1/embeddings", use_remote_service=True
|
||||
name="embedding", host=SERVICE_HOST_IP, port=6000, expose_endpoint="/v1/embeddings", use_remote_service=True
|
||||
)
|
||||
retriever = MicroService(
|
||||
name="retriever", host="0.0.0.0", port=7000, expose_endpoint="/v1/retrieval", use_remote_service=True
|
||||
name="retriever", host=SERVICE_HOST_IP, port=7000, expose_endpoint="/v1/retrieval", use_remote_service=True
|
||||
)
|
||||
rerank = MicroService(
|
||||
name="rerank", host="0.0.0.0", port=8000, expose_endpoint="/v1/reranking", use_remote_service=True
|
||||
name="rerank", host=SERVICE_HOST_IP, port=8000, expose_endpoint="/v1/reranking", use_remote_service=True
|
||||
)
|
||||
llm = MicroService(
|
||||
name="llm", host="0.0.0.0", port=9000, expose_endpoint="/v1/chat/completions", use_remote_service=True
|
||||
name="llm", host=SERVICE_HOST_IP, port=9000, expose_endpoint="/v1/chat/completions", use_remote_service=True
|
||||
)
|
||||
self.service_builder.add(embedding).add(retriever).add(rerank).add(llm)
|
||||
self.service_builder.flow_to(embedding, retriever)
|
||||
|
||||
41
ChatQnA/microservice/xeon/docker/Dockerfile
Normal file
41
ChatQnA/microservice/xeon/docker/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2024 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
FROM langchain/langchain:latest
|
||||
|
||||
RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \
|
||||
libgl1-mesa-glx \
|
||||
libjemalloc-dev \
|
||||
vim
|
||||
|
||||
RUN useradd -m -s /bin/bash user && \
|
||||
mkdir -p /home/user && \
|
||||
chown -R user /home/user/
|
||||
|
||||
RUN cd /home/user/ && \
|
||||
git clone https://github.com/opea-project/GenAIComps.git
|
||||
|
||||
RUN cd /home/user/GenAIComps && pip install --no-cache-dir --upgrade pip && \
|
||||
pip install -r requirements.txt && pip install .
|
||||
|
||||
COPY ../chatqna.py /home/user/chatqna.py
|
||||
|
||||
ENV PYTHONPATH=$PYTHONPATH:/home/user
|
||||
|
||||
USER user
|
||||
|
||||
WORKDIR /home/user
|
||||
|
||||
ENTRYPOINT ["python", "chatqna.py"]
|
||||
Reference in New Issue
Block a user