Skip to content

Commit

Permalink
fix: Use poetry and build on container start
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Jul 5, 2024
1 parent 31b1976 commit 5a3a819
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 69 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/appstore-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ jobs:
cd ${{ env.APP_NAME }}
npm ci
npm run build
- name: Download files
run: |
cd ${{ env.APP_NAME }}
make download-models
- name: Check Krankerl config
id: krankerl
Expand Down
31 changes: 11 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
FROM nvidia/cuda:12.2.2-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install -y --no-install-recommends python3.11 python3.11-venv python3-pip vim git pciutils
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
RUN apt-get -y clean
RUN rm -rf /var/lib/apt/lists/*
RUN apt update
RUN apt install -y pipx build-essential
RUN pipx install poetry

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute
ENV DEBIAN_FRONTEND=dialog

ADD li[b] /app/lib
ADD model[s] /app/models
ADD default_confi[g] /app/default_config

# Install requirements
COPY requirements.txt /
RUN python3.11 -m pip install --no-cache-dir --upgrade pip setuptools wheel
RUN python3.11 -m pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124
# RUN python3 -m pip install -vvv --no-cache-dir https://github.com/abetlen/llama-cpp-python/releases/download/v0.2.81-cu124/llama_cpp_python-0.2.81-cp311-cp311-linux_x86_64.whl
# https://github.com/abetlen/llama-cpp-python/releases/download/v0.2.81-cu122/llama_cpp_python-0.2.81-cp311-cp311-linux_x86_64.whl
RUN sed -i '/llama_cpp_python/d' requirements.txt
RUN python3.11 -m pip install --no-cache-dir --no-deps -r requirements.txt
COPY pyproject.toml /app
COPY poetry.lock /app
COPY init.sh /app
COPY healthcheck.sh /app

WORKDIR /app/lib
ENTRYPOINT ["python3", "main.py"]
WORKDIR /app
ENTRYPOINT ["bash", "init.sh"]

LABEL org.opencontainers.image.source=https://github.com/nextcloud/llm2
HEALTHCHECK --interval=2s --timeout=2s --retries=300 CMD /app/healthcheck.sh
3 changes: 3 additions & 0 deletions healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

exit 0
7 changes: 7 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash
PATH="/root/.local/bin/:$PATH"
CMAKE_ARGS="-DLLAMA_CUDA=on"
source $(poetry env info --path)/bin/activate
poetry install
cd lib
poetry run python3 main.py
2 changes: 1 addition & 1 deletion lib/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from free_prompt import FreePromptChain
from headline import HeadlineChain
from langchain.llms.llamacpp import LlamaCpp
from langchain_community.llms import LlamaCpp
from langchain.chains import LLMChain
from summarize import SummarizeChain
from topics import TopicsChain
Expand Down
53 changes: 18 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
[tool.black]
line-length = 120
target-versions = ["py310"]
preview = true
[tool.poetry]
name = "llm2"
version = "1.2.4"
description = ""
authors = ["Marcel Klehr <mklehr@gmx.net>"]
license = "AGPL-3.0"
readme = "README.md"
package-mode = false

[tool.ruff]
line-length = 120
target-version = "py310"
select = ["A", "B", "C", "D", "E", "F", "G", "I", "S", "SIM", "PIE", "Q", "RET", "RUF", "UP" , "W"]
extend-ignore = ["D101", "D102", "D103", "D105", "D107", "D203", "D213", "D401", "I001", "RUF100", "D400", "D415"]
[tool.poetry.dependencies]
python = "^3.10"
pydantic = "^2.8.2"
fastapi = "^0.111.0"
nc-py-api = {extras = ["app"], version = "^0.13.0"}
langchain = "^0.1.0"
llama-cpp-python = "0.2.76"

[tool.isort]
profile = "black"

[tool.pylint]
master.py-version = "3.10"
master.extension-pkg-allow-list = ["pydantic"]
design.max-attributes = 8
design.max-locals = 16
design.max-branches = 16
design.max-returns = 8
design.max-args = 7
basic.good-names = [
"a", "b", "c", "d", "e", "f", "i", "j", "k", "r", "v",
"ex", "_", "fp", "im", "nc", "ui",
]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
similarities.min-similarity-lines = 6
messages_control.disable = [
"missing-class-docstring",
"missing-function-docstring",
"line-too-long",
"too-few-public-methods",
"too-many-public-methods",
"global-statement",
"broad-exception-caught",
]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

0 comments on commit 5a3a819

Please sign in to comment.