downloads

package
v0.35.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package downloads manages model downloads for SpeechKit — HTTP file downloads and Ollama model pulls with progress tracking.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultStatusOptions   = StatusOptions{ProbeRuntimes: true, ProbeOllama: true}
	ReadinessStatusOptions = StatusOptions{ProbeRuntimes: true, ProbeOllama: false}
)
View Source
var DownloadURLValidation = netsec.ValidationOptions{}

DownloadURLValidation controls which URLs httpDownload accepts. Production default is strict (public https only). Tests relax this to allow loopback.

View Source
var OllamaBaseURL = "http://localhost:11434"

OllamaBaseURL is the Ollama REST API endpoint. Override in tests.

Functions

func ApplyStatus added in v0.24.0

func ApplyStatus(ctx context.Context, cfg *config.Config, items []Item, options StatusOptions)

func AvailableArtifactModelPath added in v0.35.8

func AvailableArtifactModelPath(item Item, cfg *config.Config) (string, bool)

AvailableArtifactModelPath returns the first on-disk file backing a catalog item. For whisper.cpp this includes the bundled starter model in addition to the user-writable download directory.

func FileIsPresent

func FileIsPresent(path string) bool

FileIsPresent returns true if the given path exists and is a regular file.

func OllamaModelPresent

func OllamaModelPresent(ctx context.Context, model string) bool

OllamaModelPresent quickly checks if Ollama is running and the model is pulled. It uses a short timeout so it never blocks the catalog response significantly.

func ResolveLocalLLMModelsDir added in v0.22.4

func ResolveLocalLLMModelsDir(cfg *config.Config) string

ResolveLocalLLMModelsDir returns the directory where local llama.cpp GGUF files live.

func ResolveWakewordModelsDir added in v0.34.9

func ResolveWakewordModelsDir(cfg *config.Config) string

ResolveWakewordModelsDir returns the directory where wake-word ONNX model files live. Mirrors the resolution order used for whisper/LLM models so all on-disk artifacts share one user-configurable directory.

Wake-word models are downloaded on first activation when cfg.Wakeword.Enabled is set and the model path is missing on disk. The catalog entry that drives that download lives in ArtifactCatalog() once a published .onnx URL is available; until then, power-users can place a custom hey_quby.onnx (trained via tools/wakeword-training/hey_quby.yaml) directly into this directory.

func ResolveWhisperModelsDir

func ResolveWhisperModelsDir(cfg *config.Config) string

ResolveWhisperModelsDir returns the directory where whisper model files live.

Types

type Item

type Item struct {
	ID             string `json:"id"`
	ProfileID      string `json:"profileId"`
	Name           string `json:"name"`
	Description    string `json:"description"`
	SizeLabel      string `json:"sizeLabel"`
	SizeBytes      int64  `json:"sizeBytes"`
	Kind           Kind   `json:"kind"`
	URL            string `json:"url,omitempty"`
	SHA256         string `json:"sha256,omitempty"`
	OllamaModel    string `json:"ollamaModel,omitempty"`
	License        string `json:"license"`
	Available      bool   `json:"available"`
	Selected       bool   `json:"selected"`
	RuntimeReady   bool   `json:"runtimeReady,omitempty"`
	RuntimeProblem string `json:"runtimeProblem,omitempty"`
	Recommended    bool   `json:"recommended,omitempty"`
}

Item describes a model that can be pulled into SpeechKit.

func ArtifactCatalog added in v0.24.0

func ArtifactCatalog() []Item

ArtifactCatalog returns static downloadable and pullable model artifacts. Runtime state is resolved separately so catalog consumers can decide which probes are appropriate for their context.

func Catalog

func Catalog(ctx context.Context, cfg *config.Config) []Item

Catalog returns all artifacts with the default UI-level status probes.

func CatalogWithStatus added in v0.24.0

func CatalogWithStatus(ctx context.Context, cfg *config.Config, options StatusOptions) []Item

type JobView

type JobView struct {
	ID         string  `json:"id"`
	ModelID    string  `json:"modelId"`
	ProfileID  string  `json:"profileId"`
	Status     Status  `json:"status"`
	Progress   float64 `json:"progress"`
	BytesDone  int64   `json:"bytesDone"`
	TotalBytes int64   `json:"totalBytes"`
	StatusText string  `json:"statusText"`
	Error      string  `json:"error,omitempty"`
}

JobView is the mutex-free snapshot used for JSON serialization.

type Kind

type Kind string

Kind identifies the download mechanism.

const (
	KindHTTP   Kind = "http"
	KindOllama Kind = "ollama"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager coordinates download jobs.

func NewManager

func NewManager() *Manager

NewManager creates a Manager ready to track downloads.

func (*Manager) AllJobs

func (m *Manager) AllJobs() []JobView

AllJobs returns a snapshot of every job (safe to JSON-encode).

func (*Manager) CancelJob

func (m *Manager) CancelJob(jobID string) bool

CancelJob stops an in-progress download by job ID.

func (*Manager) Start

func (m *Manager) Start(item Item, destDir string, onDone func(Item)) JobView

Start queues and launches a download. onDone is called (in a goroutine) on success. Returns the initial job snapshot.

type Status

type Status string

Status of a download job.

const (
	StatusPending   Status = "pending"
	StatusRunning   Status = "running"
	StatusDone      Status = "done"
	StatusFailed    Status = "failed"
	StatusCancelled Status = "cancelled"
)

type StatusOptions added in v0.24.0

type StatusOptions struct {
	ProbeRuntimes bool
	ProbeOllama   bool
}

StatusOptions controls which runtime checks are layered onto the static artifact catalog.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL