Proxy in front of vLLM too; dashboard reset/clear; opencode effort variants

- Move the MLX proxy into backends/proxy.py and run it on both backends:
  public port 1134 is the proxy, the model server listens on 127.0.0.1:1135.
  On vLLM this brings the reasoning chooser, the "default" alias and the
  per-request table. Effort levels the model lacks map to the nearest it has
  (high -> xhigh on qwen3.8); vLLM's own key is sent upstream; streamed runs
  are counted from the usage chunk (MTP packs several tokens per chunk).
- Dashboard: restore METRIC_RE (vLLM page stuck on "loading"); Statistics
  header with Reset, Requests header with Clear; drop the TTFT chart; rename
  token columns; Peak KV shows "-" when no samples cover a run.
- opencode: config snippet's model points at <provider>/default, and
  reasoning models get variants built from the levels the template accepts.
- README: proxy on both platforms; NVIDIA checklist split into verified / open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-03 13:03:52 -08:00
parent 1121c3f908
commit 8879db44a0
12 changed files with 886 additions and 493 deletions

View file

@ -22,7 +22,7 @@ import subprocess
from pathlib import Path
from urllib.parse import urlsplit
from . import paths, plan
from . import hfcache, paths, plan
PROVIDER = "llmhost"
DISPLAY = "LLMHost"
@ -123,6 +123,34 @@ def model_label(active, label, name_it):
return f"Default model ({label})"
# The effort levels opencode offers on its own for an OpenAI-compatible reasoning model.
# A model's template defines its own set, and one it lacks makes the template raise, so
# the block hides those and adds the model's own. (The proxy also maps a stray level to
# the nearest real one, so a pasted block that predates a switch still works.)
OPENCODE_EFFORTS = ("low", "medium", "high")
def _effort_levels(choice):
"""The active model's effort levels: from its chat template once downloaded (what the
proxy itself goes by), from the catalog before that."""
try:
entry = plan.catalog_entry(paths.load_catalog(), choice["name"])
except (KeyError, OSError, ValueError):
return ()
if not entry.get("reasoning"):
return ()
if choice.get("repo") and hfcache.repo_dir(choice["repo"]).exists():
return plan.effort_levels(entry, hfcache.template_controls(choice["repo"]))
return tuple((entry.get("effort") or {}).get("levels") or ())
def effort_variants(levels):
"""opencode `variants` for a model accepting `levels`."""
v = {l: {"disabled": True} for l in OPENCODE_EFFORTS if l not in levels}
v.update({l: {"reasoningEffort": l} for l in levels if l not in OPENCODE_EFFORTS})
return v
def provider_block(cfg, host, key_path, label, mark_loaded=False):
# A single entry, keyed by the alias the API also answers to. Listing every model that
# fits would be a menu of four things that 404 and one that works, and naming the loaded
@ -134,6 +162,9 @@ def provider_block(cfg, host, key_path, label, mark_loaded=False):
"limit": {"context": ctx, "output": min(65536, ctx // 2)}}
if (active or {}).get("reasoning"):
entry["reasoning"] = True
variants = effort_variants(_effort_levels(active))
if variants:
entry["variants"] = variants
models = {plan.SERVED_ALIAS: entry}
return {
"npm": "@ai-sdk/openai-compatible",