-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modification to toxicity plugin PR (#432)
* changed microservice to use Service.GUARDRAILS and input/output to TextDoc Signed-off-by: Tyler Wilbers <[email protected]> * simplify dockerfile to use langchain Signed-off-by: Tyler Wilbers <[email protected]> * sort requirements Signed-off-by: Tyler Wilbers <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Tyler Wilbers <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fe2fe47
commit 63650d0
Showing
5 changed files
with
43 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,31 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM ubuntu:22.04 | ||
|
||
ARG TAG=main | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
gcc-12 \ | ||
g++-12 \ | ||
make \ | ||
wget \ | ||
libnuma-dev \ | ||
numactl \ | ||
git \ | ||
pkg-config \ | ||
software-properties-common \ | ||
zlib1g-dev \ | ||
libssl-dev \ | ||
libffi-dev \ | ||
libbz2-dev \ | ||
libsqlite3-dev \ | ||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 60 \ | ||
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 60 \ | ||
&& apt-get autoremove -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install python | ||
WORKDIR /tmp | ||
RUN wget -q https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz \ | ||
&& tar -xzvf Python-3.8.10.tgz | ||
WORKDIR /tmp/Python-3.8.10 | ||
RUN ./configure --prefix=/usr/bin/python3.8 --enable-optimizations \ | ||
&& make -j \ | ||
&& make install \ | ||
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.8/bin/python3.8 60 \ | ||
&& update-alternatives --install /usr/bin/pip pip /usr/bin/python3.8/bin/pip3 60 \ | ||
&& python -m pip install --no-cache-dir --upgrade pip setuptools \ | ||
&& pip install --no-cache-dir wheel \ | ||
&& rm -rf /tmp/* \ | ||
&& echo "export PATH=/usr/bin/python3.8:\$PATH" >> ~/.bashrc | ||
|
||
RUN pip install --no-cache-dir torch==2.3.0+cpu --index-url https://download.pytorch.org/whl/cpu | ||
RUN pip install --no-cache-dir cmake==3.26.1 transformers==4.41.2 sentencepiece==0.1.99 accelerate==0.23.0 protobuf tiktoken transformers-stream-generator einops \ | ||
&& ln -s /usr/bin/python3.8/lib/python3.8/site-packages/cmake/data/bin/cmake /usr/bin/cmake | ||
|
||
COPY comps /root/comps | ||
FROM langchain/langchain:latest | ||
|
||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r /root/comps/guardrails/toxicity_detection/requirements.txt | ||
ENV LANG=C.UTF-8 | ||
|
||
ARG ARCH="cpu" | ||
|
||
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/ | ||
|
||
ENV PYTHONPATH=$PYTHONPATH:/root | ||
USER user | ||
|
||
COPY comps /home/user/comps | ||
|
||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
if [ ${ARCH} = "cpu" ]; then pip install torch --index-url https://download.pytorch.org/whl/cpu; fi && \ | ||
pip install --no-cache-dir -r /home/user/comps/guardrails/toxicity_detection/requirements.txt | ||
|
||
RUN chmod +x /root/comps/guardrails/toxicity_detection/run.sh | ||
ENV PYTHONPATH=$PYTHONPATH:/home/user | ||
|
||
WORKDIR /root/comps/guardrails/toxicity_detection/ | ||
WORKDIR /home/user/comps/guardrails/toxicity_detection/ | ||
|
||
ENTRYPOINT ["/root/comps/guardrails/toxicity_detection/run.sh"] | ||
ENTRYPOINT ["python", "toxicity_detection.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters