From ba865f3be03898a41a7ceb0dcef5df6f53092b99 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 18 Apr 2026 09:29:11 +0800 Subject: [PATCH] feat: expose /internal/models/raw for authoritative model metadata Lets callers see Lingma's raw config/queryModels response, so the official per-key displayName/description is discoverable without reverse-engineering the VSIX. Falls back to the pool's pick() unless a specific instance is requested. Made-with: Cursor --- app/main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/main.py b/app/main.py index 7526bb2..201c1c4 100644 --- a/app/main.py +++ b/app/main.py @@ -633,6 +633,36 @@ async def internal_auto_login_status(): return {"ok": True, "instances": out} +@app.get("/internal/models/raw", dependencies=[Depends(auth_guard)]) +async def internal_models_raw(instance: str | None = None): + """Return the raw `config/queryModels` response from Lingma. + + This is the authoritative source for per-key displayName, description, + capability flags, etc. We only ever extract `key` + `displayName` for + OpenAI compatibility, but clients may want to inspect everything. + """ + p = _require_pool() + target = None + if instance: + for inst in p.instances: + if inst.name == instance: + target = inst + break + if target is None: + raise HTTPException(status_code=404, detail={"error": f"instance {instance} not found"}) + else: + target = p.pick() + await _ensure_instance_logged_in(target) + raw = await target.client.query_models() + name_map = build_model_name_map(raw if isinstance(raw, dict) else {}) + return { + "instance": target.name, + "raw": raw, + "extracted_name_map": name_map, + "exposed_keys": flatten_model_keys(raw if isinstance(raw, dict) else {}), + } + + @app.get("/internal/stats", dependencies=[Depends(auth_guard)]) async def internal_stats(): p = _require_pool()