Files
teams-whisper/install.js
T

241 lines
9.9 KiB
JavaScript

// Install step list (Pinokio "Install"): detects GPU/CUDA, asks which on-prem models to download, fetches llama.cpp, diarization, embedding and VLM models, and sets up omp. Requires the "ai" bundle.
const { execFileSync } = require("child_process")
module.exports = {
requires: {
bundle: "ai"
},
run: [
// Print the detected hardware (template variables).
{
method: "log",
params: {
raw: "Hardware: {{gpu_model}} · {{vram}} GB VRAM · {{ram}} GB RAM"
}
},
{
// highest CUDA the driver supports ("CUDA Version: 13.0", newer drivers "CUDA UMD Version: 13.4" in nvidia-smi) -> llama.cpp build; no NVIDIA/driver -> CPU build
// CUDA 13 also needs compute capability >= 7.5 (Maxwell/Pascal/Volta dropped, even on R580+ drivers)
method: async (req, ondata, kernel) => {
let versionMatch = null, computeCap = 0
try { versionMatch = execFileSync("nvidia-smi", { encoding: "utf8" }).match(/CUDA (?:UMD )?Version:\s*(\d+)\.(\d+)/) } catch { /* no NVIDIA driver */ }
// lowest GPU wins
try { computeCap = Math.min(...execFileSync("nvidia-smi", ["--query-gpu=compute_cap", "--format=csv,noheader"], { encoding: "utf8" }).trim().split(/\r?\n/).map(Number)) } catch { /* no NVIDIA GPU */ }
// nvidia-smi CUDA version as major*100+minor (13.4 -> 1304); 0 when there is no NVIDIA driver.
const cudaVersion = versionMatch ? +versionMatch[1] * 100 + +versionMatch[2] : 0
// CUDA 13 (>= 1300) with compute capability >= 7.5 -> cuda-13.4 build; CUDA >= 12.04 -> cuda-12.4; otherwise CPU build.
const build = cudaVersion >= 1300 && computeCap >= 7.5 ? "cuda-13.4" : cudaVersion >= 1204 ? "cuda-12.4" : "cpu"
ondata({ raw: `CUDA: ${versionMatch ? versionMatch[1] + "." + versionMatch[2] : "none"}, compute ${computeCap || "?"} -> llama.cpp ${build}\r\n` })
return { build }
}
},
// Save the chosen build for the later download steps.
{ method: "local.set", params: { build: "{{input.build}}" } },
// on-prem LLM choice (35B needs 48+ GB RAM); transcription, diarization and embeddings always stay local
// Full on-prem choice (Qwen 35B) only with a CUDA GPU (>= 4 GB VRAM) and >= 48 GB RAM.
{
when: "{{local.build !== 'cpu' && vram >= 4 && ram >= 48}}",
method: "input",
params: {
title: "Local LLM",
description: "Transcription, speakers and search always run locally. Cloud models (GitHub Copilot / Anthropic via omp) stay selectable in the Web UI either way.",
form: [{
type: "select", key: "onprem", title: "On-prem models", default: "35b",
items: [
{ text: "Cloud only (no LLM download)", value: "none" },
{ text: "Qwen3.5 4B on-prem (~3.3 GB, all in VRAM)", value: "4b" },
{ text: "Qwen3.5 4B + Qwen3.6 35B on-prem (~26 GB, experts in RAM)", value: "35b" }
]
}]
}
},
// Save the chosen on-prem option.
{
when: "{{local.build !== 'cpu' && vram >= 4 && ram >= 48}}",
method: "local.set",
params: { onprem: "{{input.onprem}}" }
},
// Less than 48 GB RAM: the 35B option is not offered.
{
when: "{{local.build !== 'cpu' && vram >= 4 && ram < 48}}",
method: "input",
params: {
title: "Local LLM",
description: "Transcription, speakers and search always run locally. Cloud models (GitHub Copilot / Anthropic via omp) stay selectable in the Web UI either way.",
form: [{
type: "select", key: "onprem", title: "On-prem models", default: "4b",
items: [
{ text: "Cloud only (no LLM download)", value: "none" },
{ text: "Qwen3.5 4B on-prem (~3.3 GB, all in VRAM)", value: "4b" }
]
}]
}
},
{
when: "{{local.build !== 'cpu' && vram >= 4 && ram < 48}}",
method: "local.set",
params: { onprem: "{{input.onprem}}" }
},
// No usable GPU: no on-prem model choice; everything else runs on CPU.
{
when: "{{local.build === 'cpu' || vram < 4}}",
method: "log",
params: {
raw: "No CUDA GPU with 4+ GB VRAM: cloud models only; transcription, diarization and embeddings run on CPU."
}
},
// ffmpeg for audio/video handling, and 7-Zip to extract the archives (installed via conda).
{
method: "shell.run",
params: {
message: "conda install -y -c conda-forge ffmpeg 7zip"
}
},
// evaluated once, before the extract creates llama-server.exe (re-running Install must not re-download ~700 MB)
{ method: "local.set", params: { have: "{{exists('app/bin/llama-server.exe') ? 'yes' : 'no'}}" } },
// llama.cpp server (CUDA 13.4 / 12.4 / CPU build, per detection above) for the Qwen VLM + bge-m3 embeddings
{
when: "{{local.have !== 'yes'}}",
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py download https://github.com/ggml-org/llama.cpp/releases/download/b11889/llama-b11889-bin-win-{{local.build}}-x64.zip bin/llama-b11889-bin-win-{{local.build}}-x64.zip"
}
},
// CUDA runtime DLLs (cudart), downloaded separately for CUDA builds only.
{
when: "{{local.build !== 'cpu' && local.have !== 'yes'}}",
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py download https://github.com/ggml-org/llama.cpp/releases/download/b11889/cudart-llama-bin-win-{{local.build}}-x64.zip bin/cudart-llama-bin-win-{{local.build}}-x64.zip"
}
},
// Extract the llama.cpp zip into app/bin.
{
when: "{{local.have !== 'yes'}}",
method: "shell.run",
params: {
path: "app/bin",
message: "7z x -y llama-b11889-bin-win-{{local.build}}-x64.zip"
}
},
// Extract the cudart zip into the same folder.
{
when: "{{local.build !== 'cpu' && local.have !== 'yes'}}",
method: "shell.run",
params: {
path: "app/bin",
message: "7z x -y cudart-llama-bin-win-{{local.build}}-x64.zip"
}
},
// Delete the zip archives after extraction, only when they were downloaded in this run.
{
when: "{{local.have !== 'yes'}}",
method: "fs.rm",
params: {
path: "app/bin/llama-b11889-bin-win-{{local.build}}-x64.zip"
}
},
{
when: "{{local.build !== 'cpu' && local.have !== 'yes'}}",
method: "fs.rm",
params: {
path: "app/bin/cudart-llama-bin-win-{{local.build}}-x64.zip"
}
},
// speaker diarization (sherpa-onnx)
// Speaker embedding model (ERes2Net, 3D-Speaker).
{
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py download https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx models/emb.onnx"
}
},
// Pyannote segmentation model archive for sherpa-onnx.
{
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py download https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/sherpa-onnx-pyannote-segmentation-3-0.tar.bz2 models/seg.tar.bz2"
}
},
// Extract the segmentation model into app/models.
{
method: "shell.run",
params: {
path: "app/models",
message: "tar -xjf seg.tar.bz2"
}
},
// embeddings for cross-meeting memory
{
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py download https://huggingface.co/gpustack/bge-m3-GGUF/resolve/main/bge-m3-Q8_0.gguf models/bge-m3-Q8_0.gguf"
}
},
// small VLM (Qwen3.5 4B, ~3.3 GB), all layers in 4 GB VRAM: chosen at install
{
when: "{{local.onprem === '4b' || local.onprem === '35b'}}",
method: "shell.run",
params: {
path: "app",
message: [
"uv run --script llama.py download https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/main/mmproj-BF16.gguf models/qwen3.5-4b/mmproj-BF16.gguf",
"uv run --script llama.py download https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/main/Qwen3.5-4B-Q4_K_S.gguf models/qwen3.5-4b/Qwen3.5-4B-Q4_K_S.gguf"
]
}
},
// big MoE LLM + vision projector (~23 GB, experts in RAM): only when chosen at install
{
when: "{{local.onprem === '35b'}}",
method: "shell.run",
params: {
path: "app",
message: [
"uv run --script llama.py download https://huggingface.co/unsloth/Qwen3.6-35B-A3B-GGUF/resolve/main/mmproj-BF16.gguf models/mmproj-BF16.gguf",
"uv run --script llama.py download https://huggingface.co/unsloth/Qwen3.6-35B-A3B-GGUF/resolve/main/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf models/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf"
]
}
},
// pre-build the uv script environments (whisper, prefect, sherpa-onnx, openvino, ...)
{
method: "shell.run",
params: {
path: "app",
message: [
"uv sync --script flow.py",
"uv sync --script server.py",
"uv sync --script memory.py"
]
}
},
// omp (cloud auth): installed into app/bin unless already on PATH; seeds ~/.omp/agent/models.yml only if absent
{
method: "shell.run",
params: {
path: "app",
message: "uv run --script llama.py install-omp"
}
},
{
method: "notify",
params: {
html: "Installation finished ({{local.onprem === '35b' ? 'Qwen3.6 35B + Qwen3.5 4B' : local.onprem === '4b' ? 'Qwen3.5 4B' : 'cloud models only'}}; pick the model in the Web UI header). Log in to GitHub Copilot in this terminal now; Anthropic: menu 'Cloud login'."
}
},
// last: an aborted device flow cannot leave the install half done; skips itself when omp already has a valid login
{
method: "shell.run",
params: {
path: "app",
input: true,
message: ["uv run --script llama.py login github-copilot --if-needed", "exit"]
}
}
]
}