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>
This commit is contained in:
parent
8c6615dbb4
commit
2c0818ca2b
5 changed files with 78 additions and 11 deletions
|
|
@ -85,6 +85,12 @@ of remote ones at once, each named after the machine it reaches:
|
|||
| local | `llmhost` | `LLMHost (Local)` | read straight from `~/.config/llm-host/api_key` |
|
||||
| remote | `llmhost-<shorthost>` | `LLMHost (<host>)` | copied to `~/.config/opencode/llmhost-<shorthost>.key` |
|
||||
|
||||
Models are listed as `<title> · <slug> (<where>)` — `Qwen3.8 27B · qwen3.8-27b (Local)` — so the picker is
|
||||
searchable by the slug, which is the id used everywhere else (`--model llmhost/<slug>`, `llmhost switch <slug>`).
|
||||
Since only one model is loaded at a time, the local provider marks the loaded one `(Local, loaded)` and
|
||||
`llmhost switch` (and the dashboard) refresh that marker. Picking one of the others is not a silent mistake:
|
||||
the API answers `404 model_not_found` naming what is actually loaded.
|
||||
|
||||
Which block belongs to *this* machine is decided by the key-file reference it carries, not by its name. So the
|
||||
provider is still recognised after you rename it, a remote provider that happens to sit under the `llmhost` id is
|
||||
never overwritten (setup takes `llmhost-local` instead and says so), and `uninstall` removes only the local
|
||||
|
|
@ -160,6 +166,7 @@ On macOS the services are launchd agents, so they run while you're logged in.
|
|||
|
||||
## Limitations
|
||||
|
||||
- One model loaded at a time.
|
||||
- One model loaded at a time. Asking the API for a different one returns
|
||||
`404 model_not_found` naming the loaded model, rather than answering with it.
|
||||
- AMD (ROCm), Intel and CPU-only machines aren't supported yet.
|
||||
- The API and dashboard use plain HTTP and are meant for a trusted LAN. Don't expose them to the internet.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue