mirror of
https://github.com/mudler/LocalAI.git
synced 2026-08-01 02:49:51 -04:00
* feat(config): add model artifact source contract Assisted-by: Codex:GPT-5 [Codex] * feat(downloader): add authenticated raw-byte progress Assisted-by: Codex:GPT-5 [Codex] * feat(huggingface): resolve immutable snapshot manifests Assisted-by: Codex:GPT-5 [Codex] * feat(models): add artifact storage primitives Assisted-by: Codex:GPT-5 [Codex] * feat(models): materialize pinned Hugging Face snapshots Assisted-by: Codex:GPT-5 [Codex] * feat(models): bind managed snapshots at runtime Assisted-by: Codex:GPT-5 [Codex] * feat(gallery): materialize model artifacts during install Assisted-by: Codex:GPT-5 [Codex] * feat(gallery): declare managed Hugging Face artifacts Assisted-by: Codex:GPT-5 [Codex] * feat(models): preload managed model artifacts Assisted-by: Codex:GPT-5 [Codex] * fix(gallery): retain shared artifact caches on delete Assisted-by: Codex:GPT-5 [Codex] * feat(models): report artifact acquisition progress Assisted-by: Codex:GPT-5 [Codex] * refactor(backends): load managed models from ModelFile Assisted-by: Codex:GPT-5 [Codex] * refactor(backends): load staged speech model snapshots Assisted-by: Codex:GPT-5 [Codex] * refactor(backends): use staged snapshots in engine backends Assisted-by: Codex:GPT-5 [Codex] * test(distributed): cover staged artifact snapshots Assisted-by: Codex:GPT-5 [Codex] * docs: explain managed model artifacts Assisted-by: Codex:GPT-5 [Codex] * docs: add product design context Assisted-by: Codex:GPT-5 [Codex] * feat(ui): show model artifact download progress Assisted-by: Codex:GPT-5 [Codex] * Eagerly materialize Hugging Face artifacts Materialize HF-backed model references as managed GGUF artifacts during load, with lazy download retained only as fallback. Assisted-by: Codex:GPT-5 [shell] * Refactor HF downloads through a shared executor Assisted-by: Codex:GPT-5 [shell] * drop Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package galleryop
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
|
|
"github.com/mudler/LocalAI/pkg/modelartifacts"
|
|
)
|
|
|
|
type artifactProgressBridge struct {
|
|
mu sync.Mutex
|
|
last float64
|
|
currentBytes int64
|
|
totalBytes int64
|
|
update func(*OpStatus)
|
|
}
|
|
|
|
func newArtifactProgressBridge(update func(*OpStatus)) *artifactProgressBridge {
|
|
return &artifactProgressBridge{update: update}
|
|
}
|
|
|
|
func (b *artifactProgressBridge) Sink(event modelartifacts.ProgressEvent) {
|
|
b.mu.Lock()
|
|
progress := b.last
|
|
message := "Preparing model files"
|
|
switch event.Phase {
|
|
case modelartifacts.PhaseResolving:
|
|
progress = max(progress, 0)
|
|
message = "Resolving model files"
|
|
case modelartifacts.PhaseDownloading:
|
|
if event.TotalBytes > 0 {
|
|
progress = max(progress, min(90, float64(event.CurrentBytes)*90/float64(event.TotalBytes)))
|
|
}
|
|
message = fmt.Sprintf("Downloading model file: %s", event.File)
|
|
case modelartifacts.PhaseVerifying:
|
|
progress = max(progress, 95)
|
|
message = "Verifying model files"
|
|
case modelartifacts.PhaseCommitting:
|
|
progress = max(progress, 99)
|
|
message = "Finalizing model installation"
|
|
case modelartifacts.PhasePersisting:
|
|
progress = max(progress, 99)
|
|
message = "Saving model configuration"
|
|
}
|
|
b.last = progress
|
|
b.currentBytes = max(b.currentBytes, event.CurrentBytes)
|
|
b.totalBytes = max(b.totalBytes, event.TotalBytes)
|
|
status := &OpStatus{
|
|
Phase: string(event.Phase), Message: message, FileName: event.File,
|
|
Progress: progress, CurrentBytes: b.currentBytes, TotalBytes: b.totalBytes,
|
|
Cancellable: true,
|
|
}
|
|
update := b.update
|
|
b.mu.Unlock()
|
|
if update != nil {
|
|
update(status)
|
|
}
|
|
}
|
|
|
|
func (b *artifactProgressBridge) ClampLegacy(progress float64) float64 {
|
|
b.mu.Lock()
|
|
defer b.mu.Unlock()
|
|
b.last = max(b.last, progress)
|
|
return b.last
|
|
}
|