diff --git a/.github/workflows/build-and-release-docker.yml b/.github/workflows/build-and-release-docker.yml new file mode 100644 index 0000000000..178f8ce45a --- /dev/null +++ b/.github/workflows/build-and-release-docker.yml @@ -0,0 +1,39 @@ +name: Build Release + +on: push + +jobs: + build_docker: + name: Build docker images + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "true" + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.22.x' + + - name: Build libllama.so + working-directory: ./vendor/llama.cpp + run: | + mkdir build + cd build + cmake .. -D LLAMA_STANDALONE=OFF -D LLAMA_AVX512=OFF -D BUILD_SHARED_LIBS=ON -D LLAMA_BUILD_TESTS=OFF -D LLAMA_BUILD_EXAMPLES=OFF + cmake --build . --config Release + + - name: Copy libllama.so to lib folder and rename + run: | + mkdir lib + cp ./vendor/llama.cpp/build/libllama.so ./lib/llama.so + + - uses: actions/upload-artifact@v3 + with: + name: libllama + path: ./lib/ + + diff --git a/.gitignore b/.gitignore index fd64c09b37..d8bc66fbeb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,6 @@ __pycache__/ *.py[cod] *$py.class -# C extensions -*.so - # Distribution / packaging .Python build/ @@ -20,7 +17,6 @@ dist/ downloads/ eggs/ .eggs/ -lib/ lib64/ parts/ sdist/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..e5b91a0623 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.10 + +# Install dependencies + +#Copy the compiled llama.so file to the container +COPY ./lib /lib/ + +#Set the environment variable for the llama.so file +ENV LLAMA_CPP_LIB /lib/llama.so + +# Copy the python code to the container +RUN mkdir -p /app +COPY ./llama_cpp /app +WORKDIR /app + +#Add the current directory to the PYTHONPATH +ENV PYTHONPATH "${PYTHONPATH}:/app" + +# Install Requirements +RUN --mount=type=cache,target=/root/.cache/pip pip3 install -r ./server/requirements.txt + +#Set default environment variables +ENV HOST 0.0.0.0 +ENV PORT 8000 + +#Expose the port +EXPOSE ${PORT} + +#Run the server +CMD ["python3","-m","server"] + + diff --git a/lib/llama.so b/lib/llama.so new file mode 100644 index 0000000000..7cafef69a7 Binary files /dev/null and b/lib/llama.so differ diff --git a/llama_cpp/server/requirements.txt b/llama_cpp/server/requirements.txt new file mode 100644 index 0000000000..b0bdc92396 --- /dev/null +++ b/llama_cpp/server/requirements.txt @@ -0,0 +1,4 @@ +fastapi +pydantic +uvicorn +sse-starlette \ No newline at end of file