refactor(llm): Share one model table type across providers - #1212
Merged
Merged
Conversation
The OpenAI, Google, Anthropic and Cerebras providers each kept their hand-maintained model facts in a `match` over model ids. They now use a shared `Catalog<T>` in `jp_llm::model::catalog`, named `MODEL_OVERRIDES` with a `model_overrides(id)` lookup in every provider. An entry lists its canonical id and any aliases (dated snapshots, `-latest` pointers, `gpt-5.6` / `gpt-5.6-sol`), and a lookup under an alias still reports the id the caller named. Each provider keeps its own value type: `ModelDetails` where the API reports little or nothing, and `ModelOverrides` for Anthropic, whose table only fills gaps in the capabilities API. A `match` could look up one id but could not be iterated, so OpenAI kept a separate `SUBSCRIPTION_MODELS` list for subscription credentials, and it had drifted: `gpt-6-sol` and `gpt-6-luna` were marked as served by a ChatGPT subscription but missing from the list. The list is now derived from the entries marked `subscription: Some(true)`, so a subscription credential lists both models, and the two can no longer disagree. Every provider has a test that no id is claimed by two entries, which the compiler used to catch as an unreachable `match` arm. Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OpenAI, Google, Anthropic and Cerebras providers each kept their hand-maintained model facts in a
matchover model ids. They now use a sharedCatalog<T>injp_llm::model::catalog, namedMODEL_OVERRIDESwith amodel_overrides(id)lookup in every provider. An entry lists its canonical id and any aliases (dated snapshots,-latestpointers,gpt-5.6/gpt-5.6-sol), and a lookup under an alias still reports the id the caller named. Each provider keeps its own value type:ModelDetailswhere the API reports little or nothing, andModelOverridesfor Anthropic, whose table only fills gaps in the capabilities API.A
matchcould look up one id but could not be iterated, so OpenAI kept a separateSUBSCRIPTION_MODELSlist for subscription credentials, and it had drifted:gpt-6-solandgpt-6-lunawere marked as served by a ChatGPT subscription but missing from the list. The list is now derived from the entries markedsubscription: Some(true), so a subscription credential lists both models, and the two can no longer disagree.Every provider has a test that no id is claimed by two entries, which the compiler used to catch as an unreachable
matcharm.