Consolidated local ollama model logic
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_OVERRIDE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
export ROOT_OVERRIDE
|
||||
# shellcheck disable=SC1091
|
||||
source "${ROOT_OVERRIDE}/scripts/common.sh"
|
||||
|
||||
init_log update-native
|
||||
print_header "update-native: START"
|
||||
|
||||
need_cmd curl
|
||||
need_cmd python
|
||||
need_cmd ollama
|
||||
load_env
|
||||
check_for_legacy_docker_ollama
|
||||
|
||||
log "update-native: waiting for Ollama API at ${OLLAMA_URL}"
|
||||
wait_for_ollama_api "$OLLAMA_URL" 120 || fail "Ollama API not reachable at ${OLLAMA_URL}" 50
|
||||
ok "update-native: Ollama API reachable"
|
||||
|
||||
log "update-native: pulling base model ${BASE_MODEL}"
|
||||
ollama pull "${BASE_MODEL}"
|
||||
|
||||
if [[ -n "${EXTRA_MODELS}" ]]; then
|
||||
for m in ${EXTRA_MODELS}; do
|
||||
log "update-native: pulling extra model ${m}"
|
||||
ollama pull "$m"
|
||||
done
|
||||
fi
|
||||
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
render_modelfile "$tmp"
|
||||
|
||||
log "update-native: rebuilding expert model ${EXPERT_MODEL}"
|
||||
ollama create "${EXPERT_MODEL}" -f "$tmp"
|
||||
|
||||
tags="$(fetch_tags)"
|
||||
printf '%s' "$tags" | is_json || fail "/api/tags did not return valid JSON" 51
|
||||
model_in_tags "$BASE_MODEL" "$tags" || fail "base model missing after update: ${BASE_MODEL}" 52
|
||||
model_in_tags "$EXPERT_MODEL" "$tags" || fail "expert model missing after update: ${EXPERT_MODEL}" 53
|
||||
ok "update-native: base and expert models are available"
|
||||
|
||||
warmup_sqlai
|
||||
print_footer "update-native: END status=OK log=${LOG_FILE}"
|
||||
Reference in New Issue
Block a user