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>
This commit is contained in:
parent
51c2880a2e
commit
9af7f1e545
6 changed files with 124 additions and 50 deletions
|
|
@ -164,8 +164,9 @@ def _uncached(usage):
|
|||
|
||||
|
||||
def make_handler(inner_port, served_name, context, key, stats, aliases=(), reasoning=None):
|
||||
# Names a client may call the loaded model: its llm-host name and its repo id.
|
||||
accepted = {served_name.lower(), *(a.lower() for a in aliases if a)}
|
||||
# Names a client may call the loaded model: its llm-host name, its repo id, and the
|
||||
# stable alias that means "whatever is loaded" (plan.SERVED_ALIAS).
|
||||
accepted = {served_name.lower(), plan.SERVED_ALIAS, *(a.lower() for a in aliases if a)}
|
||||
|
||||
class Proxy(BaseHTTPRequestHandler):
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
|
@ -222,7 +223,9 @@ def make_handler(inner_port, served_name, context, key, stats, aliases=(), reaso
|
|||
self._json(404, {"error": {
|
||||
"message": f"model '{want}' is not loaded; this server is serving "
|
||||
f"'{served_name}'. Load it with `llmhost switch {want}` "
|
||||
f"(one model is loaded at a time), or ask for '{served_name}'.",
|
||||
f"(one model is loaded at a time), or ask for '{served_name}' "
|
||||
f"-- or for '{plan.SERVED_ALIAS}', which always means whatever "
|
||||
f"is loaded.",
|
||||
"type": "invalid_request_error", "code": "model_not_found", "param": "model"}})
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue