Documentation
¶
Index ¶
- Constants
- Variables
- func GeminiModelSupportsVision(modelName string) bool
- func OpenAIModelSupportsVision(modelName string) bool
- func ValidateDescriptor(name string, descriptor ModelDescriptor) error
- type CompletionProfile
- type EmbeddingProfile
- type FamilyGroup
- type ModelDescriptor
- func (d ModelDescriptor) AutoAcquirable() bool
- func (d ModelDescriptor) AutoHotContext(budget int64) int
- func (d ModelDescriptor) AutoHotContextType(budget int64, kvType string) int
- func (d ModelDescriptor) BackendType() string
- func (d ModelDescriptor) BytesForHotContext(tokens int) int64
- func (d ModelDescriptor) ContextMemoryBytes(tokens int, kvType string) int64
- func (d ModelDescriptor) EstimatedResidentBytes() int64
- func (d ModelDescriptor) Label() string
- func (d ModelDescriptor) RecommendedVRAMLabel() string
- func (d ModelDescriptor) RoleMemoryBytes(role, kvType string) int64
- func (d ModelDescriptor) SupportsAgenticTools() bool
- func (d ModelDescriptor) SupportsCompletion() bool
- func (d ModelDescriptor) SupportsNextEdit() bool
- func (d ModelDescriptor) SupportsRetrieval() bool
- type NextEditProfile
- type Registry
- type Source
Constants ¶
const AgenticTierAgentic = "agentic"
AgenticTierAgentic marks a model evidenced to run a multi-step tool loop; automatic selection picks nothing below it.
const AgenticTierNone = "none"
AgenticTierNone marks a model whose template the runtime cannot read calls from, whatever its card claims.
const AgenticTierToolChat = "tool-chat"
AgenticTierToolChat marks a model that calls tools but is not evidenced to sustain a loop: fine for a smoke test or a one-shot question, not for an agent working a task.
const CompletionFIM = "fim"
CompletionFIM is native fill-in-the-middle decoding without a chat chain.
const CompletionInstruct = "instruct"
CompletionInstruct is code insertion through an instruction-following chat chain, not native FIM decoding.
const CompletionPrompt = "prompt"
CompletionPrompt is code insertion through one bounded instruction-prompt request.
const CuratedModelsSchemaFile = "curated_models.json"
CuratedModelsSchemaFile is the validated schema holding the curated catalog.
const MinAgenticHotContext = 32 * 1024
MinAgenticHotContext is the usable context automatic selection requires. An agent spends it on the tool catalogue before it spends it on the task: a large tool surface costs thousands of tokens of schema on every call, and the turns before this one have to fit beside it. A model that cannot hold this much can call a tool once and then runs out, so a bigger window is not a reason to pick it — the window has to be usable.
Variables ¶
var ErrNoAutoModel = errors.New("no eligible automatic model")
ErrNoAutoModel means no eligible model fits the requested origin, backend, and memory.
var ErrNotFound = errors.New("model not found in registry")
Functions ¶
func ValidateDescriptor ¶
func ValidateDescriptor(name string, descriptor ModelDescriptor) error
ValidateDescriptor rejects a catalog entry that is incomplete for the roles it claims.
Types ¶
type CompletionProfile ¶
type CompletionProfile struct {
FIMFormat string `json:"fimFormat,omitempty"`
Mode string `json:"mode"`
ContextTokens int `json:"contextTokens"`
Evidence string `json:"evidence"`
}
CompletionProfile describes the execution mode, required context, and evidence for code completion.
type EmbeddingProfile ¶
type EmbeddingProfile struct {
Pooling string `json:"pooling"`
ContextTokens int `json:"contextTokens"`
Dimension int `json:"dimension"`
Normalize bool `json:"normalize"`
QueryPrefix string `json:"queryPrefix"`
DocumentPrefix string `json:"documentPrefix"`
Evidence string `json:"evidence"`
}
EmbeddingProfile describes a dedicated retrieval model's execution and input contract.
type FamilyGroup ¶ added in v0.33.0
type FamilyGroup struct {
Family string
Entries []ModelDescriptor
}
FamilyGroup is a display grouping of descriptors sharing the same Family.
func GroupByFamily ¶ added in v0.33.0
func GroupByFamily(entries []ModelDescriptor) []FamilyGroup
GroupByFamily groups entries by Family (falling back to Name when Family is empty) and sorts groups by family name and entries within a group by SizeBytes ascending. It is a pure display helper — it takes no context and hits no DB.
type ModelDescriptor ¶
type ModelDescriptor struct {
// Pipeline is the exported OpenVINO GenAI diffusion pipeline class in model_index.json.
Pipeline string `json:"pipeline,omitempty"`
// Completion declares the code-completion execution contract and its curated evidence.
Completion CompletionProfile `json:"completion,omitempty"`
// NextEdit declares the edit-prediction contract and its curation evidence.
NextEdit NextEditProfile `json:"nextEdit,omitempty"`
// Embedding declares the retrieval embedding contract and its curated evidence.
Embedding EmbeddingProfile `json:"embedding,omitempty"`
// AutoContextLimit is the verified native context ceiling, without extrapolation.
AutoContextLimit int `json:"autoContextLimit,omitempty"`
// AutoKVProfile conservatively estimates hot f16 KV storage before download.
AutoKVProfile capacity.LayerKVProfile `json:"autoKVProfile,omitempty"`
Origin string `json:"origin,omitempty"`
ReleasedAt string `json:"releasedAt,omitempty"`
License string `json:"license,omitempty"`
AutoEligible bool `json:"autoEligible,omitempty"`
ID string `json:"id,omitempty" example:"m1a2b3c4-d5e6-f7g8-h9i0-j1k2l3m4n5o6"`
Name string `json:"name" example:"qwen3-8b"`
SourceURL string `json:"sourceUrl" example:"https://huggingface.co/Qwen/..."`
// SourceSHA256 is the reviewed digest of the single-file model download.
SourceSHA256 string `json:"sourceSha256,omitempty"`
SizeBytes int64 `json:"sizeBytes" example:"934000000"`
Curated bool `json:"curated" example:"true"`
// Backend is the local backend this model targets: "" or "llama" for GGUF,
// "openvino" for an OpenVINO IR model. It selects the models/<backend>/
// directory and the pull strategy (single GGUF file vs multi-file IR repo).
Backend string `json:"backend,omitempty" example:"openvino"`
// Repo is the Hugging Face repo id for multi-file pulls (OpenVINO IR). For
// GGUF models SourceURL points at the single file and Repo is empty.
Repo string `json:"repo,omitempty" example:"OpenVINO/Qwen3-8B-int4-ov"`
// Revision pins every file of a multi-file model to one reviewed repository snapshot.
Revision string `json:"revision,omitempty"`
// TokenizerCompanionID selects the embedded OpenVINO tokenizer bundle for this model's native code operation.
TokenizerCompanionID string `json:"tokenizerCompanionId,omitempty"`
// ToolProtocol is the backend-native tool-call parser protocol (for example
// "llama:common_chat_tool_parser" or "openvino:...").
// Set when the pinned backend has a compatible template parser; `model pull` writes it into
// the model's profile so the local provider enables tool calls out of the box.
ToolProtocol string `json:"toolProtocol,omitempty" example:"llama:common_chat_tool_parser"`
// ReasoningProtocol is the local backend's parser for model-emitted reasoning
// text. `model pull` writes it into the
// model's profile so the provider can separate visible output from thinking.
ReasoningProtocol string `json:"reasoningProtocol,omitempty" example:"llama:common_chat_reasoning_parser"`
// ReasoningFormat is the backend-native reasoning format passed to the parser
// and chat-template renderer, for example llama.cpp common-chat "deepseek".
ReasoningFormat string `json:"reasoningFormat,omitempty" example:"deepseek"`
// Family groups related size/quant variants of the same model line for
// display (e.g. "qwen3", "gemma4", "phi-4"). It is a presentation grouping
// key, not a capability signal.
Family string `json:"family,omitempty" example:"qwen3"`
// DisplayLabel is the human-readable name shown in listings, e.g.
// "Qwen 3 8B". Falls back to Name when empty.
DisplayLabel string `json:"displayLabel,omitempty" example:"Qwen 3 8B"`
// UseCase is the primary workflow this curated entry is meant to serve,
// e.g. "coding", "chat", "reasoning", or "smoke".
UseCase string `json:"useCase,omitempty" example:"coding"`
// AgenticTier is the curation-side capability signal automatic selection
// gates on: "agentic" when the model is evidenced to run a multi-step tool
// loop, "tool-chat" when it can call a tool but not sustain one, and "none"
// when the runtime cannot read calls from its template at all. A model the
// catalogue cannot vouch for is not picked automatically however much
// context it can hold — a large window on a model that cannot use it is not
// a capability.
AgenticTier string `json:"agenticTier,omitempty" example:"agentic"`
// AgenticEvidence is why that tier was assigned: the measured multi-turn
// result where one exists, the training provenance where the current
// generation has no published benchmark, or the reason it falls short.
AgenticEvidence string `json:"agenticEvidence,omitempty" example:"official BFCL v4 multi-turn 41.75%"`
// RecommendedVRAMGB is the coarse VRAM tier this curated entry is intended
// for before live modeld capacity data is available. It is advisory only:
// modeld still resolves the real hot-KV/effective-context fit from current
// device free memory, resident policy, KV profile, and runtime overhead.
RecommendedVRAMGB int `json:"recommendedVramGb,omitempty" example:"8"`
// Vision marks curated entries whose artifacts carry the full vision stack
// (multimodal projector beside the GGUF for llama; vision encoder models in
// the IR snapshot for OpenVINO), so modeld can serve image input. It is the
// curation-side capability signal only — the live truth stays modeld's
// Describe answer (ModelInfo.SupportsVision), which the providers thread
// into CapabilityConfig.CanVision.
Vision bool `json:"vision,omitempty" example:"true"`
// MMProjURL is the multimodal projector GGUF for llama vision entries.
// `model pull` fetches it beside the model as mmproj.gguf — the filename
// modeld resolves the projector from — and fails loudly when the projector
// cannot be fetched instead of leaving a silently text-only model. Empty for
// text entries and for OpenVINO entries (their multi-file snapshot already
// includes the vision models).
MMProjURL string `json:"mmprojUrl,omitempty" example:"https://huggingface.co/.../mmproj-....gguf"`
// MMProjSizeBytes is the projector file size for download reporting.
MMProjSizeBytes int64 `json:"mmprojSizeBytes,omitempty" example:"559874816"`
// ChatTemplateURL is the model's own chat template, for entries whose GGUF
// does not embed tokenizer.chat_template — which is most community quants.
// `model pull` fetches it as chat_template.jinja beside the model, where
// modeld reads it and hands it to llama.cpp in place of the GGUF's template.
// Without it llama.cpp falls back to its built-in ChatML template, which
// declares no tool-call markers: tools are never rendered in the dialect the
// model was trained on, and its calls come back as prose.
ChatTemplateURL string `json:"chatTemplateUrl,omitempty" example:"https://huggingface.co/…/chat_template.jinja"`
// Notes is a short free-text annotation shown alongside the model in
// listings, e.g. "native tool format", "MoE", "fastest smoke test".
Notes string `json:"notes,omitempty" example:"native tool format"`
}
ModelDescriptor describes a downloadable model and its backend requirements.
func SelectAuto ¶
func SelectAuto(origin, backend string, budget int64) (ModelDescriptor, error)
SelectAuto picks the model an unattended setup should run: one curated as able to sustain a multi-step tool loop, holding at least MinAgenticHotContext of usable context within the memory budget, for the requested developer origin and backend.
Capability gates the choice and context only qualifies it. The order that used to stand here preferred whichever model could reach a 128K hot window, which is how a 0.8B model came to be installed on machines that could run a 9B one: a large window on a model that cannot use it is not a capability. Among models that clear the gate the larger one wins — parameter count is a weak signal across families and a fair one inside a tier — and release date is not a tiebreak at all, so a new release does not displace a model that already does the job. SelectAuto is only reached for a machine that has no working pick yet; the caller keeps the previous model while it still qualifies, so a model is never swapped for a marginal gain.
func SelectAutoType ¶
func SelectAutoType(origin, backend string, budget int64, kvType string) (ModelDescriptor, error)
SelectAutoType is SelectAuto for a machine whose worker runs the given KV cache type. The caller must pass what modeld will actually allocate: the estimate is only as honest as the type it is given.
func SelectRole ¶
func SelectRole(candidates []ModelDescriptor, role, origin, backend string, budget int64, kvType string) (ModelDescriptor, error)
SelectRole selects the lowest-resident-cost explicitly qualified role candidate. Completion is chosen at the tier where it is good enough rather than at the largest tier that fits: a stronger predictor buys nothing the user can feel, while the memory it holds is capacity Chat, Next Edit and retrieval cannot use on the same device. Names and workflow labels are not evidence.
func (ModelDescriptor) AutoAcquirable ¶
func (d ModelDescriptor) AutoAcquirable() bool
AutoAcquirable reports whether automatic setup may download and assign this artifact. Automatic setup acts on the user's behalf, which only a permissive license allows.
func (ModelDescriptor) AutoHotContext ¶
func (d ModelDescriptor) AutoHotContext(budget int64) int
AutoHotContext estimates genuinely resident context using the curated KV profile. Budget is usable device memory after hardware reservations. Weights and a conservative runtime allowance are deducted; cold or planner capacity is excluded. The opened modeld session reports the actual hot allocation after download.
func (ModelDescriptor) AutoHotContextType ¶
func (d ModelDescriptor) AutoHotContextType(budget int64, kvType string) int
AutoHotContextType is AutoHotContext at a KV cache quantization. It has to be the type the worker will run — modeld takes it from CONTENOX_LLAMA_KV_CACHE_TYPE — because a quantized cache is what buys a small card its window: at f16 a 32K window costs more than the whole budget on the models that fit a 6 GB device, and half that at q8_0.
func (ModelDescriptor) BackendType ¶ added in v0.32.2
func (d ModelDescriptor) BackendType() string
BackendType returns the local backend this model targets, defaulting empty to "llama" for GGUF descriptors.
func (ModelDescriptor) BytesForHotContext ¶
func (d ModelDescriptor) BytesForHotContext(tokens int) int64
BytesForHotContext is the memory budget that would give this model the given hot context at f16, the inverse of ModelDescriptor.AutoHotContext.
func (ModelDescriptor) ContextMemoryBytes ¶
func (d ModelDescriptor) ContextMemoryBytes(tokens int, kvType string) int64
ContextMemoryBytes estimates weights, runtime overhead and KV for a reviewed context within the qualified native ceiling.
func (ModelDescriptor) EstimatedResidentBytes ¶ added in v0.33.0
func (d ModelDescriptor) EstimatedResidentBytes() int64
EstimatedResidentBytes is a coarse pre-install RAM/VRAM estimate (on-disk weight size — including the multimodal projector for vision entries — plus ~25% headroom for KV cache and runtime overhead at a moderate context length). It is NOT modeld's real KV-aware capacity.Resolve budget computed from the live device and the model's actual KV profile — only a rough signal for picking a model before modeld is even installed.
func (ModelDescriptor) Label ¶ added in v0.33.0
func (d ModelDescriptor) Label() string
Label returns DisplayLabel, falling back to Name when no display label was set.
func (ModelDescriptor) RecommendedVRAMLabel ¶ added in v0.33.0
func (d ModelDescriptor) RecommendedVRAMLabel() string
RecommendedVRAMLabel formats the advisory curated VRAM tier for display.
func (ModelDescriptor) RoleMemoryBytes ¶
func (d ModelDescriptor) RoleMemoryBytes(role, kvType string) int64
RoleMemoryBytes estimates resident weights, runtime allowance and the role's required KV context.
func (ModelDescriptor) SupportsAgenticTools ¶
func (d ModelDescriptor) SupportsAgenticTools() bool
SupportsAgenticTools reports whether this entry is curated as able to run a multi-step tool loop, which is the baseline automatic selection requires.
func (ModelDescriptor) SupportsCompletion ¶
func (d ModelDescriptor) SupportsCompletion() bool
SupportsCompletion reports an explicit native FIM, chat-chain, or prompt completion contract.
func (ModelDescriptor) SupportsNextEdit ¶
func (d ModelDescriptor) SupportsNextEdit() bool
SupportsNextEdit reports an explicit supported edit contract with curation evidence.
func (ModelDescriptor) SupportsRetrieval ¶
func (d ModelDescriptor) SupportsRetrieval() bool
SupportsRetrieval reports an explicit, complete dedicated embedding contract.
type NextEditProfile ¶
type NextEditProfile struct {
Format string `json:"format"`
ContextTokens int `json:"contextTokens"`
Evidence string `json:"evidence"`
}
NextEditProfile describes a model's independent edit-prediction operation.
type Registry ¶
type Registry interface {
// Resolve returns the descriptor for name from curated or user-added entries.
Resolve(ctx context.Context, name string) (*ModelDescriptor, error)
// List returns all known descriptors (curated + user-added). User entries override curated SourceURL.
List(ctx context.Context) ([]ModelDescriptor, error)
// OptimalFor returns the best registry name for an arbitrary model name string.
// Exact match → family mapping → fallback.
OptimalFor(ctx context.Context, modelName string) (string, error)
}
func NewCurated ¶
func NewCurated() Registry
NewCurated returns the built-in registry without a user-entry source.
type Source ¶
type Source interface {
GetByName(context.Context, string) (*runtimetypes.ModelRegistryEntry, error)
List(context.Context, *time.Time, int) ([]*runtimetypes.ModelRegistryEntry, error)
}
Source supplies user registry entries layered over the curated catalog.