ModelResolver
Category: Catalog
Source: model_resolver.dart
Turns a user-typed model identifier into a concrete [ModelRef].
Two policies matter here:
Explicit
provider/idis 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.Bare ids must match exactly. Case-insensitive equality against
model.idormodel.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
const ModelResolution()ResolvedExact
The input maps to a specific entry in the catalog.
Constructor
const ResolvedExact({required this.ref, required this.def})Properties
| Property | Type | Description |
|---|---|---|
ref | ModelRef | |
def | ModelDef |
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
const ResolvedPassthrough({required this.ref, this.providerKnown = true})Properties
| Property | Type | Description |
|---|---|---|
ref | ModelRef | |
providerKnown | bool | True 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
const AmbiguousBareInput({required this.raw, required this.candidates})Properties
| Property | Type | Description |
|---|---|---|
raw | String | |
candidates | List<ModelCandidate> |
UnknownBareInput
A bare input with no slash matched nothing in the catalog.
Constructor
const UnknownBareInput({required this.raw})Properties
| Property | Type | Description |
|---|---|---|
raw | String |
ModelCandidate
Constructor
const ModelCandidate({required this.ref, required this.def})Properties
| Property | Type | Description |
|---|---|---|
ref | ModelRef | |
def | ModelDef |
Functions
ModelResolution resolveModelInput(String raw, ModelCatalog catalog)
Resolve [raw] against [catalog]. See library doc for the rules.