359afb3a59
Infrastructure configs for GMKtec K11 (Docker, vLLM, LocalAI, ComfyUI, control-plane, gpu-fan agent, Server UI with CLI/file explorer/GPU fan curve). Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.8 KiB
Bash
Executable File
64 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Shared helpers for models.catalog.yaml (simple parser, no PyYAML required).
|
|
|
|
CATALOG_FILE="${CATALOG_FILE:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/models.catalog.yaml}"
|
|
|
|
catalog_list_ids() {
|
|
grep '^ - id:' "${CATALOG_FILE}" | awk '{print $3}'
|
|
}
|
|
|
|
catalog_get_field() {
|
|
local model_id="$1"
|
|
local field="$2"
|
|
awk -v id="${model_id}" -v key="${field}:" '
|
|
$0 ~ "^ - id: " id "$" { found=1; next }
|
|
found && $0 ~ "^ - id:" { exit }
|
|
found && index($0, key) == 5 { sub(/^ [^:]+: /, ""); print; exit }
|
|
' "${CATALOG_FILE}"
|
|
}
|
|
|
|
catalog_ensure_dirs() {
|
|
local data_root="${1:-/data}"
|
|
mkdir -p \
|
|
"${data_root}/apps/vllm/huggingface" \
|
|
"${data_root}/apps/gguf/qwen3.6-27b" \
|
|
"${data_root}/apps/gguf/gemma-4-12b"
|
|
}
|
|
|
|
catalog_model_downloaded() {
|
|
local model_id="$1"
|
|
local runtime
|
|
runtime="$(catalog_get_field "${model_id}" runtime)"
|
|
|
|
case "${runtime}" in
|
|
vllm)
|
|
local hf_model
|
|
hf_model="$(catalog_get_field "${model_id}" hf_model)"
|
|
local cache="${DATA_ROOT:-/data}/apps/vllm/huggingface"
|
|
# Heuristic: HF hub cache contains repo name
|
|
local repo_path
|
|
repo_path=$(echo "${hf_model}" | tr '/' '--')
|
|
if find "${cache}/hub" -maxdepth 3 -type d -name "models--${repo_path}" 2>/dev/null | grep -q .; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
;;
|
|
llamacpp)
|
|
local local_path local_dir gguf_file
|
|
local_path="$(catalog_get_field "${model_id}" local_path)"
|
|
local_dir="$(catalog_get_field "${model_id}" local_dir)"
|
|
gguf_file="$(catalog_get_field "${model_id}" gguf_file)"
|
|
if [[ -n "${local_path}" && -f "${local_path}" ]]; then
|
|
return 0
|
|
fi
|
|
if [[ -n "${local_dir}" && -n "${gguf_file}" && -f "${local_dir}/${gguf_file}" ]]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|