refactor(models): read model metadata from the live catalog - #20
Conversation
Drop the hardcoded default model id and read ids, display names, descriptions and context windows from GET /v1/models instead. `init` runs before an API key exists, so it names no model and points at `gonkagate models`, which now prints the live context window and the first catalog entry as the default. Absent or null enrichment fields degrade to `n/a` or are omitted, so gateways that do not publish them yet keep working. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
e97a6fe to
8ba7371
Compare
|
Reworked: the hardcoding approach in this PR has been replaced with live model metadata. Why. The earlier revision added the model by writing What replaced it.
Compatibility. gonka-proxy#70 is merged but not deployed, so this had to work against today's
The branch was squashed and force-pushed so the superseded |
What changed
This PR originally hardcoded a new model into the CLI. That approach is replaced: the CLI now reads
model metadata from the live catalog instead of carrying a copy of it.
Hardcoded before
src/commands/init.ts:export const DEFAULT_MODEL_ID = 'deepseek-ai/deepseek-v4-flash-0731',plus a doc comment asserting its 400K context window.
.envtemplate wrote# GONKAGATE_MODEL=deepseek-ai/deepseek-v4-flash-0731.README.mdnamed the same id twice as the suggested default, once with "400K context".Every one of those is gone. Nothing in
src/orREADME.mdnames a model id or a context windowany more.
Read live now
GET /v1/modelsis the only source of truth for the catalog.gonkagate modelsrenders the live context window in a newcontextcolumn, and prints eachmodel's display name and description under
--verbosewhen the gateway provides them.--jsonalready carried
contextLength/name/description; that is unchanged.models[0], the first entry in response order. It is printed asDefault model: <id> (first entry returned by /v1/models)and exposed as a new top-leveldefaultModelfield in--json. There is no client-side sort, ranking or preference heuristic,and no hardcoded default id.
gonkagate initruns before an API key exists, so it genuinely cannot fetch the catalog. Ratherthan guess, the template now leaves
GONKAGATE_MODELcommented and unset and points the userat
gonkagate models. This is the one place metadata could not be read live, and the honestanswer there is to name nothing.
Behaviour against a gateway that has NOT shipped gonka-proxy#70
The fallback path is the default path, not an afterthought. Against today's gateway, which returns
only
id/object/created/owned_by:nullcontext_length/contextLengthn/a; key omitted from--json. Never0, nevernull.namename:line in--verbose.descriptioncontext_lengthandcontextLengthare both accepted (pre-existing tolerance, kept). Onlyidisrequired; a model without one is skipped, and an empty list is still the existing
MODELS_ERROR.defaultModelneeds nothing beyondid, so it works on today's gateway too.Four new
tests/models.integration.test.tscases prove both sides: an ids-only response, an enrichedresponse, an explicit all-
nullresponse, and response-order-defines-the-default (asserted in bothdirections so a hidden sort would fail).
Kept from the original approach
The
cwdoption oninitand its integration test, and the removal of the deadllama-3.1-70bplaceholder from the
.envtemplate.Validation
Run locally on Node 20+, all from a clean
npm ci:npm ci --no-audit --no-fundnpm run format:checknpm run lintnpm run typechecknpm testmain)npm run builddist/cli.js58.24 KBnpm run ciAlso verified by hand against a local stub gateway, in both shapes:
and with the enriched fields stripped (today's gateway), where every row reads
n/aand the commandstill exits 0.
Notes
feat(models): add DeepSeek V4 Flash 0731 as the default GonkaGate modelcommit was removed on purpose: this repo merges with merge commitsenabled and release-please builds
CHANGELOG.mdfrom commit subjects, so leaving it would havepublished a release note for a change that no longer exists.
qwen/qwen3-235b-a22b-instruct-2507-fp8andllama-3.1-*references indocs/and inunrelated test fixtures are untouched; they are sample data, not a catalog the CLI reads.
🤖 Generated with Claude Code