Add explanatory comments across codebase

This commit is contained in:
Stefano Zini
2026-11-04 14:23:18 +01:00
parent b8aa5548a2
commit 82b72b6c28
34 changed files with 934 additions and 0 deletions
+17
View File
@@ -1,3 +1,4 @@
// 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 = {
@@ -5,6 +6,7 @@ module.exports = {
bundle: "ai"
},
run: [
// Print the detected hardware (template variables).
{
method: "log",
params: {
@@ -19,14 +21,18 @@ module.exports = {
try { m = execFileSync("nvidia-smi", { encoding: "utf8" }).match(/CUDA (?:UMD )?Version:\s*(\d+)\.(\d+)/) } catch (e) {}
// lowest GPU wins
try { cc = Math.min(...execFileSync("nvidia-smi", ["--query-gpu=compute_cap", "--format=csv,noheader"], { encoding: "utf8" }).trim().split(/\r?\n/).map(Number)) } catch (e) {}
// nvidia-smi CUDA version as major*100+minor (13.4 -> 1304); 0 when there is no NVIDIA driver.
const v = m ? +m[1] * 100 + +m[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 = v >= 1300 && cc >= 7.5 ? "cuda-13.4" : v >= 1204 ? "cuda-12.4" : "cpu"
ondata({ raw: `CUDA: ${m ? m[1] + "." + m[2] : "none"}, compute ${cc || "?"} -> 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",
@@ -43,11 +49,13 @@ module.exports = {
}]
}
},
// 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",
@@ -68,6 +76,7 @@ module.exports = {
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",
@@ -75,6 +84,7 @@ module.exports = {
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: {
@@ -92,6 +102,7 @@ module.exports = {
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",
@@ -100,6 +111,7 @@ module.exports = {
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",
@@ -108,6 +120,7 @@ module.exports = {
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",
@@ -116,6 +129,7 @@ module.exports = {
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",
@@ -131,6 +145,7 @@ module.exports = {
}
},
// speaker diarization (sherpa-onnx)
// Speaker embedding model (ERes2Net, 3D-Speaker).
{
method: "shell.run",
params: {
@@ -138,6 +153,7 @@ module.exports = {
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: {
@@ -145,6 +161,7 @@ module.exports = {
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: {