Files
teams-whisper/app/llama.py
T
pinokioandClaude Opus 5.5 4ff3e6fe14 Add Pinokio launcher for Teams meeting report pipeline
Pipeline code copied into app/; llama.py now uses launcher-local
llama.cpp (app/bin) and Qwen GGUF (app/models) instead of LM Studio.
install.js fetches ffmpeg, 7zip, llama.cpp CUDA 13, sherpa-onnx
diarization models, bge-m3 and Qwen3.6-35B-A3B, then pre-builds the
uv script environments. start.js serves the GUI on fixed port 18765
(hardcoded in the browser extension). reset.js keeps app/out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 21:29:33 +01:00

32 lines
1.6 KiB
Python

import subprocess, time, urllib.request
from pathlib import Path
SERVER = Path(__file__).parent / "bin" / "llama-server.exe"
MD = Path(__file__).parent / "models"
MODEL, MMPROJ = MD / "Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf", MD / "mmproj-BF16.gguf"
PORT = 18081
EMBED, EMBED_PORT = Path(__file__).parent / "models" / "bge-m3-Q8_0.gguf", 18082
_open = urllib.request.build_opener(urllib.request.ProxyHandler({})).open # corp proxy must not see localhost
def up(port=PORT):
try: _open(f"http://127.0.0.1:{port}/health", timeout=2); return True
except Exception: return False
def _spawn(args, port, log):
if up(port): return None
p = subprocess.Popen([str(SERVER), *args, "--port", str(port)], stdout=open(log, "w"), stderr=subprocess.STDOUT)
for _ in range(600):
if up(port): return p
assert p.poll() is None, f"llama-server died, see {log}"
time.sleep(2)
raise TimeoutError("llama-server not ready")
def start(model=MODEL, mmproj=MMPROJ, port=PORT, log="llama.log"):
"""Start llama-server (attention on GPU, MoE experts on CPU: fits 4 GB). None if already running."""
return _spawn(["-m", str(model), "--mmproj", str(mmproj), "-ngl", "99", "--cpu-moe", "-c", "16384", "--jinja"], port, log)
def start_embed(log="embed.log"):
"""bge-m3 embeddings on CPU (never competes with the GPU model). None if already running."""
if not EMBED.exists(): raise FileNotFoundError(f"{EMBED} missing: hf download gpustack/bge-m3-GGUF bge-m3-Q8_0.gguf --local-dir models")
return _spawn(["-m", str(EMBED), "--embeddings", "--pooling", "cls", "-ngl", "0", "-c", "8192", "-b", "2048", "-ub", "2048"], EMBED_PORT, log)