ModelSpec class

Everything the app needs to provision and run one model: artifact URLs, engine configuration, the ChatFormat it speaks, and sampling defaults.

Specs are plain data declared in model_registry.dart; services (download, load, chat client construction) consume whichever spec is registered, so switching models is a registry change, not a code hunt.

Constructors

ModelSpec({required String id, required String displayName, required Uri modelUrl, Uri? mmprojUrl, int? imageTokenBudget, ImageTiling? imageTiling, Uri? draftUrl, required int contextSize, int maxSequences = 1, int gpuLayers = 999, int draftGpuLayers = 999, int maxDraftTokens = 3, required ChatFormat format, SamplingDefaults sampling = const SamplingDefaults(), String engineId = 'llama', bool filterTools = true, bool enableThinking = true})

Properties

contextSize → int
Context window the engine allocates at load time.
final
displayName → String
Human-readable name for UI surfaces.
final
draftGpuLayers → int
GPU offload hint for the speculative-decoding drafter; only meaningful when draftUrl (or a locally selected draft artifact) is configured.
final
draftUrl → Uri?
The speculative-decoding drafter pairing with modelUrl, or null to decode single-model.
final
enableThinking → bool
Whether to inject the family's reasoning channel (Gemma's <|think|> marker) ahead of each answer.
final
engineId → String
Which inference engine runs this spec. Today only 'llama' exists.
final
filterTools → bool
Whether per-turn keyword tool selection applies to this model's prompts.
final
format → ChatFormat
The model family's prompt wire format.
final
gpuLayers → int
GPU offload hint (llama.cpp layer count; 999 = everything on Metal). Engines that don't split layers ignore it.
final
hashCode → int
The hash code for this object.
no setteroverride
id → String
Stable identifier, e.g. 'gemma-4-e4b-it-q4km'.
final
imageTiling → ImageTiling?
How to split attached images into overlapping crops before prompt rendering, or null to pass images through whole.
final
imageTokenBudget → int?
Vision-encoder token budget per image, or null for the model's metadata default.
final
maxDraftTokens → int
Upper bound on tokens the drafter proposes per speculation step.
final
maxSequences → int
Number of independent KV-cache sequences the engine allocates (llama.cpp n_seq_max). Engines without sequence support ignore it.
final
mmprojUrl → Uri?
The multimodal projector pairing with modelUrl (mtmd vision), or null for a text-only model.
final
modelUrl → Uri
Where the model weights are downloaded from.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sampling → SamplingDefaults
Sampling parameters used when ChatOptions doesn't override them.
final

Methods

copyWith({String? id, String? displayName, Uri? modelUrl, Uri? mmprojUrl, int? imageTokenBudget, ImageTiling? imageTiling, Uri? draftUrl, int? contextSize, int? maxSequences, int? gpuLayers, int? draftGpuLayers, int? maxDraftTokens, ChatFormat? format, SamplingDefaults? sampling, String? engineId, bool? filterTools, bool? enableThinking}) → ModelSpec
Returns a copy with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override