From 2b636b97e252db6eac565266257eb926eacb983f Mon Sep 17 00:00:00 2001 From: juvdiaz Date: Wed, 10 Jun 2026 10:35:22 -0600 Subject: [PATCH] Add Ollama translation model command --- README.md | 7 +++++++ lab.sh | 32 +++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 01d995f..7dfb0f1 100644 --- a/README.md +++ b/README.md @@ -657,6 +657,13 @@ custom `website-translator` Ollama model defined in `apps/website/ollama/Modelfile`. Generated runtime language JSON is saved through `save_lang.php` on the website PVC. +Create or refresh the Ollama model on the Debian server before deploying a +website image that points at it: + +```bash +./lab.sh website-translation-model +``` + The CV page has two client-side presentation modes: - `Elegant`: dark, minimal, terminal-inspired styling with a square profile diff --git a/lab.sh b/lab.sh index a977bfe..abb0c70 100755 --- a/lab.sh +++ b/lab.sh @@ -2893,6 +2893,33 @@ refresh_argocd_application() { kubectl --kubeconfig "${KUBECONFIG}" patch application "${app}" -n argocd --type merge -p '{"metadata":{"annotations":{"argocd.argoproj.io/refresh":"hard"}}}' >/dev/null } +website_translation_model() { + local model_name="${WEBSITE_TRANSLATION_MODEL:-website-translator}" + local modelfile="${WEBSITE_TRANSLATION_MODELFILE:-${REPO_ROOT}/apps/website/ollama/Modelfile}" + + require_debian_server "website-translation-model" + + if ! command -v ollama >/dev/null 2>&1; then + echo "ollama is not installed or not in PATH on this Debian server." >&2 + exit 1 + fi + + if [[ ! -r "${modelfile}" ]]; then + echo "Ollama Modelfile is not readable: ${modelfile}" >&2 + exit 1 + fi + + echo "Creating or updating Ollama model ${model_name} from ${modelfile}..." + ollama create "${model_name}" -f "${modelfile}" + + if ! ollama list | awk -v model="${model_name}" 'NR > 1 && ($1 == model || $1 == model ":latest") { found = 1 } END { exit found ? 0 : 1 }'; then + echo "Ollama model ${model_name} was not found after creation." >&2 + exit 1 + fi + + echo "Ollama model ${model_name} is ready." +} + apps() { local buildx_builder_ready=false local demos_image_built=false @@ -3244,6 +3271,9 @@ case "${1:-}" in apps) apps ;; + website-translation-model) + website_translation_model + ;; deploy-gitea) deploy_gitea ;; @@ -3272,7 +3302,7 @@ case "${1:-}" in nuke ;; *) - echo "Usage: $0 {up|rebuild-cluster|apps|deploy-gitea|bootstrap-gitea-repo|backup-gitea|drill-gitea-restore|install-gitea-runner|move-prometheus-stack-workers|doctor-versions|openwrt|nuke}" + echo "Usage: $0 {up|rebuild-cluster|apps|website-translation-model|deploy-gitea|bootstrap-gitea-repo|backup-gitea|drill-gitea-restore|install-gitea-runner|move-prometheus-stack-workers|doctor-versions|openwrt|nuke}" exit 1 ;; esac