Skip to content

ModelResolver ​

Category: Catalog

Source: model_resolver.dart

Turns a user-typed model identifier into a concrete [ModelRef].

Two policies matter here:

  1. Explicit provider/id is sacred. When the input parses as a [ModelRef], we never fuzzy-match. If the pair exists in the catalog we return [ResolvedExact]; otherwise we pass it through verbatim as [ResolvedPassthrough]. This lets users target freshly-pulled Ollama tags or off-catalog API ids without the catalog rewriting their input.

  2. Bare ids must match exactly. Case-insensitive equality against model.id or model.name, across every provider. Zero hits → [UnknownBareInput]. Exactly one → [ResolvedExact]. Multiple → [AmbiguousBareInput] with the candidate list; the caller decides whether to surface a disambiguation prompt or error.

Substring fallback is intentionally absent — the previous behaviour silently rewrote gemma4 into gemma4:26b, which masked real input errors.

Classes ​

sealed ModelResolution ​

The outcome of [resolveModelInput].

Constructor ​

dart
const ModelResolution()

ResolvedExact ​

The input maps to a specific entry in the catalog.

Constructor ​

dart
const ResolvedExact({required this.ref, required this.def})

Properties ​

PropertyTypeDescription
refModelRef
defModelDef

ResolvedPassthrough ​

The input was an explicit provider/id for a provider Glue knows about but a model that isn't in the curated catalog. Send it to the provider as-is; the user knows what they're asking for.

Constructor ​

dart
const ResolvedPassthrough({required this.ref, this.providerKnown = true})

Properties ​

PropertyTypeDescription
refModelRef
providerKnownboolTrue when providerId resolves to a registered provider. False means the user typed foo/bar and foo is nowhere in the catalog — the caller should surface this as an error rather than trying to use it.

AmbiguousBareInput ​

A bare input matched multiple catalog entries. The caller should ask the user to disambiguate with <provider>/<id>.

Constructor ​

dart
const AmbiguousBareInput({required this.raw, required this.candidates})

Properties ​

PropertyTypeDescription
rawString
candidatesList<ModelCandidate>

UnknownBareInput ​

A bare input with no slash matched nothing in the catalog.

Constructor ​

dart
const UnknownBareInput({required this.raw})

Properties ​

PropertyTypeDescription
rawString

ModelCandidate ​

Constructor ​

dart
const ModelCandidate({required this.ref, required this.def})

Properties ​

PropertyTypeDescription
refModelRef
defModelDef

Functions ​

ModelResolution resolveModelInput(String raw, ModelCatalog catalog) ​

Resolve [raw] against [catalog]. See library doc for the rules.

Released under the MIT License.