Commit graph

8 commits

Author SHA1 Message Date
Neil Bantoc
e24c0b7712 Reasoning effort is the dashboard's to set, not the client's
One model is loaded at a time under one setting, and that setting belongs next
to the model it applies to -- the same reason the client can't switch models.
So the proxy now takes a client's reasoning settings off the request before
applying the dashboard's: a top-level reasoning_effort, and enable_thinking or
reasoning_effort inside chat_template_kwargs. Other template kwargs, which
llm-host has no opinion about, still pass through.

This reverses the precedence the proxy had (a client's own kwargs won, mirroring
mlx_lm's own rule), which was the wrong model for a single-model server: clients
offer a generic menu -- opencode's low/medium/high -- and a level the template
doesn't define makes it raise, so every request failed with nothing on the
user's screen to explain it.

- opencode: the provider block disables all three of opencode's effort levels
  instead of curating them. A chooser there would be a menu that does nothing.
- Deletes the nearest-effort mapping (EFFORT_SCALE, nearest_effort,
  plan.effort_levels, the effort_levels= parameter through both backends): it
  existed only to rescue a client-supplied level, and none survives now.
- plan.REASONING_KEYS names the knobs this server drives, with a test asserting
  it stays exactly equal to what reasoning_kwargs can emit -- so a new template
  knob can't be added without also taking it away from clients.
- Two strings that still described a menu of models, from before the block held
  a single entry.

Verified against the live MLX server: with the dashboard on xhigh, five request
shapes (nothing, enable_thinking: false, effort low top-level, effort low in
kwargs, and the off-scale "turbo" that used to 404) all answer identically, and
the reply tracks the dashboard alone as it moves off / low / xhigh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-03 15:01:26 -08:00
neil
8879db44a0 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>
2026-11-03 13:03:52 -08:00
Neil Bantoc
9af7f1e545 opencode: offer one model, not a menu where four of five fail
Only one model is loaded at a time, so listing every model that fits gave a
picker with one working entry and four that now answer 404 -- and the entry that
worked changed id on every `llmhost switch`, invalidating any client's saved
default.

Replace the list with a single entry, `default`, which is a name the API itself
answers to: vLLM takes it as a second --served-model-name and still reports the
real slug, being first in the list; the MLX proxy accepts it as an alias. So
`llmhost/default` survives a switch. The local entry is labelled with whatever is
loaded, refreshed by both switch paths; a remote block is pasted once and never
refreshed, so it names no model rather than make a claim that goes stale.

Existing configs point at a specific model, which this provider no longer has and
opencode would reject, so configure() and sync() migrate `<prov>/<model>` to
`<prov>/default`. Other providers' defaults are untouched, and an older remote
block that still lists many models keeps working, including as the fallback when
the local provider is removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-03 02:26:34 -08:00
Neil Bantoc
2c0818ca2b Refuse a request for a model that isn't loaded; show the slug in /models
The MLX proxy rewrote every request's "model" to the preloaded one, so asking
for a model the server wasn't running returned another model's output wearing
the requested name -- silently. The rewrite itself has to stay (mlx_lm would
otherwise try to load a model matching the name), so validate first: a name
that is neither the served name nor its repo id gets 404 model_not_found,
naming what is loaded and how to switch. An unstated name still means "the
loaded one", and the key is still checked before the model.

opencode's /models hid the same trap twice over. Label models
`<title> · <slug> (<where>)` so the list is searchable by the id used
everywhere else -- titles alone had dropped the slug -- and mark the loaded
one `(Local, loaded)`, refreshed by both switch paths (CLI and dashboard)
through a new opencode.sync(), which only ever refreshes a block that is
already there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-03 00:38:35 -08:00
Neil Bantoc
8c6615dbb4 opencode: clear the cached key, and let --purge keep the API key
opencode caches a provider's key in ~/.local/share/opencode/auth.json and that
copy wins over opencode.json: with a stale entry it fails auth without sending
a request at all and asks for the key interactively. Verified by A/B on a live
install -- correct entry works, wrong entry never reaches the server, absent
entry works and reads the key file.

llm-host mints a fresh key whenever the config dir is purged, so the cached
copy went stale on every reinstall. configure() now drops the entry for its own
provider, leaving the {file:...} reference authoritative; it tracks the key file
and cannot go stale. remove() takes the cached key with the provider. Other
providers' credentials are never touched, and an unreadable store is left alone
rather than repaired.

Add `uninstall --purge --keep-key` so the key survives a purge and a reinstall
reuses it -- clients elsewhere then keep working. Warn about the new key when
it doesn't. Factor the purge into purge() so it can be tested without touching
a real install.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-03 00:19:54 -08:00
Neil Bantoc
13a7def080 opencode: label models with the catalog title, not the slug
/models showed "qwen3.8-27b (Local)" where the catalog already has a name
meant for reading: "Qwen3.8 27B". The dict key stays the slug -- that is the
model id the API answers to -- so only the display name changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-02 23:52:31 -08:00
Neil Bantoc
504ea3018a opencode: name providers LLMHost (Local) / LLMHost (<host>), identify by key file
The local and remote setup paths already used distinct provider ids, so one
opencode config can point at a local server and any number of remote ones.
Name them after the machine they reach so they're tellable apart in /models.

Decide which block is *this* machine's by the key-file reference it carries
rather than by its name, so:

  - a provider renamed by hand is still recognised and updated in place
    instead of a second one being added next to it;
  - a remote provider sitting under the `llmhost` id is no longer silently
    overwritten with a localhost baseURL (setup takes `llmhost-local` and
    says so) -- the one-shot .before-llmhost backup could not recover it;
  - uninstall removes only the local provider, never `llmhost-*` blocks for
    servers that are still running, and never providers it didn't create.

Add `llmhost opencode-remove` for the case the servers can't handle for each
other: uninstalling on a server can't reach the clients pointing at it. Wire
uninstall to it, repointing opencode's default model at a surviving llm-host
provider and dropping `model` only when none is left.

Also split config read/write out of configure() and report `unparsable`: a
syntactically broken opencode.json used to raise ValueError mid-setup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-02 23:42:18 -08:00
neil
7ad0642d2e Offer to install opencode and connect it to the local server
After setup, if opencode is missing, offer to install it with its
official installer; then add an `llmhost` provider pointing at
http://localhost:<api port>/v1 that reads llm-host's key file directly.
Other providers and the default model are kept, the original config is
backed up once, trailing commas are tolerated, and a config with
comments is left untouched (the block is printed instead). Re-runs and
`llmhost update` keep the provider's port and models in sync.
New: `llmhost opencode-setup`, and setup flags --opencode / --no-opencode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
2026-11-02 05:37:35 -08:00