MCPcopy
hub / github.com/mudler/LocalAI / installModel

Function installModel

core/startup/model_preload.go:85–107  ·  view source on GitHub ↗
(ctx context.Context, galleries, backendGalleries []config.Gallery, modelName string, systemState *system.SystemState, modelLoader *model.ModelLoader, downloadStatus func(string, string, string, float64), enforceScan, autoloadBackendGalleries, requireBackendIntegrity bool)

Source from the content-addressed store, hash-verified

83}
84
85func installModel(ctx context.Context, galleries, backendGalleries []config.Gallery, modelName string, systemState *system.SystemState, modelLoader *model.ModelLoader, downloadStatus func(string, string, string, float64), enforceScan, autoloadBackendGalleries, requireBackendIntegrity bool) (error, bool) {
86 models, err := gallery.AvailableGalleryModels(galleries, systemState)
87 if err != nil {
88 return err, false
89 }
90
91 model := gallery.FindGalleryElement(models, modelName)
92 if model == nil {
93 return err, false
94 }
95
96 if downloadStatus == nil {
97 downloadStatus = utils.DisplayDownloadFunction
98 }
99
100 xlog.Info("installing model", "model", modelName, "license", model.License)
101 err = gallery.InstallModelFromGallery(ctx, galleries, backendGalleries, systemState, modelLoader, modelName, gallery.GalleryModel{}, downloadStatus, enforceScan, autoloadBackendGalleries, requireBackendIntegrity)
102 if err != nil {
103 return err, true
104 }
105
106 return nil, true
107}

Callers 1

InstallModelsFunction · 0.85

Calls 3

AvailableGalleryModelsFunction · 0.92
FindGalleryElementFunction · 0.92
InstallModelFromGalleryFunction · 0.92

Tested by

no test coverage detected