diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index fb68a847..82150bf0 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -21,6 +21,7 @@ jobs: MODEL_SERVICE_IMAGE: locallm-model-service CHATBOT_IMAGE: locallm-chatbot SUMMARIZER_IMAGE: locallm-text-summarizer + CODEGEN_IMAGE: locallm-codegen RAG_IMAGE: locallm-rag CHROMADB_IMAGE: locallm-chromadb steps: @@ -49,6 +50,13 @@ jobs: files: | summarizer-langchain/** + - name: Get changed code-generation files + id: changed-files-codegen + uses: tj-actions/changed-files@v42 + with: + files: | + code-generation/** + - name: Get changed chatbot files id: changed-files-chatbot uses: tj-actions/changed-files@v42 @@ -64,14 +72,14 @@ jobs: rag-langchain/builds/chromadb/** - name: Install qemu dependency - if: steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' + if: steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true' run: | sudo apt-get update sudo apt-get install -y qemu-user-static - name: Login Quay Container registry if: > - (steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-chromadb.outputs.any_changed == 'true') && + (steps.changed-files-model-service.outputs.any_changed == 'true' || steps.changed-files-chatbot.outputs.any_changed == 'true' || steps.changed-files-summarizer.outputs.any_changed == 'true' || steps.changed-files-rag.outputs.any_changed == 'true' || steps.changed-files-chromadb.outputs.any_changed == 'true' || steps.changed-files-codegen.outputs.any_changed == 'true') && (github.event_name == 'push' || github.event_name == 'schedule') && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) uses: redhat-actions/podman-login@v1 @@ -127,6 +135,30 @@ jobs: tags: ${{ steps.build_chatbot_multiplatform.outputs.tags }} registry: ${{ env.REGISTRY }} + - name: Build code-generation + if: steps.changed-files-codegen.outputs.any_changed == 'true' + id: build_summarizer_multiplatform + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.CODEGEN_IMAGE }} + tags: latest ${{ github.sha }} + platforms: linux/amd64, linux/arm64 + context: code-generation + containerfiles: | + ./code-generation/builds/Containerfile + + - name: Push code-generation image + id: push_codegen + if: > + (steps.changed-files-codegen.outputs.any_changed == 'true') && + (github.event_name == 'push' || github.event_name == 'schedule') && + (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build_codegen_multiplatform.outputs.image }} + tags: ${{ steps.build_codegen_multiplatform.outputs.tags }} + registry: ${{ env.REGISTRY }} + - name: Build summarizer if: steps.changed-files-summarizer.outputs.any_changed == 'true' id: build_summarizer_multiplatform diff --git a/code-generation/quadlet/README.md b/code-generation/quadlet/README.md new file mode 100644 index 00000000..dfcfb5fb --- /dev/null +++ b/code-generation/quadlet/README.md @@ -0,0 +1,10 @@ +### Run code-generation as a systemd service + +```bash +cp codegen.yaml /etc/containers/systemd/codegen.yaml +cp codegen.kube.example /etc/containers/codegen.kube +cp codegen.image /etc/containers/codegen.image +/usr/libexec/podman/quadlet --dryrun (optional) +systemctl daemon-reload +systemctl start codegen +``` diff --git a/code-generation/quadlet/codegen.image b/code-generation/quadlet/codegen.image new file mode 100644 index 00000000..9fc113ae --- /dev/null +++ b/code-generation/quadlet/codegen.image @@ -0,0 +1,7 @@ +[Install] +WantedBy=codegen.service + +[Image] +Image=quay.io/sallyom/models:mistral-7b-gguf +Image=quay.io/redhat-et/locallm-model-service:latest +Image=quay.io/redhat-et/locallm-codegen:latest diff --git a/code-generation/quadlet/codegen.kube.example b/code-generation/quadlet/codegen.kube.example new file mode 100644 index 00000000..3c64098e --- /dev/null +++ b/code-generation/quadlet/codegen.kube.example @@ -0,0 +1,16 @@ +[Unit] +Description=Python script to run against downloaded LLM +Documentation=man:podman-generate-systemd(1) +Wants=network-online.target +After=network-online.target +RequiresMountsFor=%t/containers + +[Kube] +# Point to the yaml file in the same directory +Yaml=codegen.yaml + +[Service] +Restart=always + +[Install] +WantedBy=default.target diff --git a/code-generation/quadlet/codegen.yaml b/code-generation/quadlet/codegen.yaml new file mode 100644 index 00000000..873c5442 --- /dev/null +++ b/code-generation/quadlet/codegen.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + app: codegen-langchain + name: codegen-langchain +spec: + initContainers: + - name: model-file + image: quay.io/sallyom/models:mistral-7b-gguf + command: ['/usr/bin/install', "/model/mistral-7b-instruct-v0.1.Q4_K_S.gguf", "/shared/"] + volumeMounts: + - name: model-file + mountPath: /shared + containers: + - env: + - name: MODEL_SERVICE_ENDPOINT + value: http://10.88.0.1:8001/v1 + image: quay.io/redhat-et/locallm-codegen:latest + name: codegen-inference + ports: + - containerPort: 8501 + hostPort: 8501 + securityContext: + runAsNonRoot: true + - env: + - name: HOST + value: 0.0.0.0 + - name: PORT + value: 8001 + - name: MODEL_PATH + value: /model/mistral-7b-instruct-v0.1.Q4_K_S.gguf + image: quay.io/redhat-et/locallm-model-service:latest + name: codegen-model-service + ports: + - containerPort: 8001 + hostPort: 8001 + securityContext: + runAsNonRoot: true + volumeMounts: + - name: model-file + mountPath: /model + volumes: + - name: model-file + emptyDir: {}