Documentation
¶
Overview ¶
Package models manages the local model cache: catalog manifests (teraflock/models format), resumable GGUF downloads with SHA256 verification, and LRU eviction under the operator's disk budget.
Index ¶
- Variables
- func LocalArtifactPath(artifactURL string) (string, bool)
- type Catalog
- type CatalogModel
- type Info
- type Manager
- func (m *Manager) Ensure(ctx context.Context, spec *typesv1.ModelSpec) (string, error)
- func (m *Manager) List() []Info
- func (m *Manager) Path(id string) string
- func (m *Manager) Pin(id string, pinned bool) error
- func (m *Manager) Remove(id string) error
- func (m *Manager) Touch(id string)
- func (m *Manager) Verify(id string) error
Constants ¶
This section is empty.
Variables ¶
var ErrSHAMismatch = errors.New("models: sha256 mismatch")
ErrSHAMismatch means a downloaded artifact failed verification. The daemon refuses to serve hash-mismatched files (SPEC §6).
Functions ¶
func LocalArtifactPath ¶
LocalArtifactPath reports whether an artifact_url points at a file already on this machine, and returns its filesystem path. Both `file:///abs/path` and a bare absolute path are accepted — operators writing a local catalog by hand reach for the latter.
This is how a node serves an existing GGUF collection (LM Studio, ollama, hand-built quants) without re-downloading gigabytes it already has.
Types ¶
type Catalog ¶
type Catalog struct {
Models []CatalogModel `yaml:"models" json:"models"`
}
Catalog is the manifest format of the teraflock/models repo (catalog/*.yaml). JSON is accepted too.
func LoadCatalog ¶
LoadCatalog reads a catalog from a local path or URL (one must be set; path wins).
func ParseCatalog ¶
ParseCatalog decodes YAML or JSON manifest bytes.
type CatalogModel ¶
type CatalogModel struct {
ID string `yaml:"id" json:"id"`
Family string `yaml:"family" json:"family"`
ParamsB float64 `yaml:"params_b" json:"params_b"`
Quant string `yaml:"quant" json:"quant"`
SHA256 string `yaml:"sha256" json:"sha256"`
MinVRAMMB uint64 `yaml:"min_vram_mb" json:"min_vram_mb"`
MinRAMMB uint64 `yaml:"min_ram_mb" json:"min_ram_mb"`
License string `yaml:"license" json:"license"`
ArtifactURL string `yaml:"artifact_url" json:"artifact_url"`
SizeBytes uint64 `yaml:"size_bytes" json:"size_bytes"`
PayoutClass string `yaml:"payout_class" json:"payout_class"`
ContextLength uint32 `yaml:"context_length" json:"context_length"`
Embeddings bool `yaml:"embeddings" json:"embeddings"`
}
CatalogModel is one curated model entry.
func (CatalogModel) Spec ¶
func (m CatalogModel) Spec() *typesv1.ModelSpec
Spec converts a catalog entry to the proto ModelSpec.
type Info ¶
type Info struct {
ID string `json:"id"`
SizeBytes int64 `json:"size_bytes"`
Pinned bool `json:"pinned"`
LastUsed time.Time `json:"last_used"`
State string `json:"state"`
}
Info is a local cache listing row.
type Manager ¶
type Manager struct {
Dir string
MaxDiskMB int64
Client *http.Client
Log *slog.Logger
// contains filtered or unexported fields
}
Manager owns <data_dir>/models: downloads, verification, pins and LRU eviction under the disk budget.
func NewManager ¶
NewManager loads (or initializes) the cache state.
func (*Manager) Ensure ¶
Ensure makes the model available locally: verified cache hit, resumed partial download, or full download. Returns the local path.